hugo without theme
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
{{/*
|
||||
GetHeaderImage
|
||||
|
||||
This partial gets the resource for the header image for a given page.
|
||||
|
||||
If a header_image was set in the page's front matter, then that will be used.
|
||||
|
||||
If not set, this will search page resources to find an image that contains the word
|
||||
"cover", and if found, returns the path to that resource.
|
||||
|
||||
If no header_image was set, and there's no "cover" image in page resources, then
|
||||
this partial returns an empty string (which evaluates to false).
|
||||
|
||||
@return Resource of header image, or an empty string if not found.
|
||||
|
||||
*/}}
|
||||
|
||||
{{ $headerImage := "" }}
|
||||
|
||||
{{/* Defined as params */}}
|
||||
{{ if isset .context.Params .name }}
|
||||
{{ $image_name := .context.Param .name }}
|
||||
{{ with .context.Resources.GetMatch $image_name }}
|
||||
{{ $headerImage = . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
{{/* Defined as resource */}}
|
||||
{{ if $headerImage }}
|
||||
{{ else }}
|
||||
{{ if .context.Resources.GetMatch .name }}
|
||||
{{ $img := .context.Resources.GetMatch .name }}
|
||||
{{ with $img }}
|
||||
{{ $headerImage = . }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Find the first image with 'cover' in the name in this page bundle. */}}
|
||||
{{ else }}
|
||||
{{ $img := (.context.Resources.ByType "image").GetMatch "*cover*" }}
|
||||
{{ with $img }}
|
||||
{{ $headerImage = . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* return either a Resource, or an empty string. Note that partials can only have a single
|
||||
return statement, so this needs to be at the end of the partial (and not in the if block) */}}
|
||||
{{ return $headerImage }}
|
||||
@@ -0,0 +1,26 @@
|
||||
{{/*
|
||||
HeatMeterTile
|
||||
|
||||
This partial visualizes a value to it's max value in a small tile. Inputs are following items:
|
||||
two number values "value" and "max" and integer "precision" and "unit" for printing the value, "color".
|
||||
|
||||
@return -
|
||||
|
||||
*/}}
|
||||
{{ $x := 0 }}
|
||||
{{ if gt .max 0 }}
|
||||
{{ $x = mul ( div 100.0 (float .max ) ) (float .value ) }}
|
||||
{{ else }}
|
||||
{{ $x = 0 }}
|
||||
{{ end }}
|
||||
|
||||
{{ $output := partial "func/NumberFormatter.html" ( dict "number" .value "precision" .precision ) }}
|
||||
|
||||
|
||||
<svg width="98" height="50" xmlns="http://www.w3.org/2000/svg">
|
||||
<!-- Created with Method Draw - http://github.com/duopixel/Method-Draw/ -->
|
||||
<rect height="100%" width="100%" opacity="0.4" fill="{{ .color }}"/>
|
||||
<rect height="100%" width="{{ $x }}" fill="{{ .color }}"/>
|
||||
<text xml:space="preserve" text-anchor="middle" font-family="Helvetica, Arial, sans-serif"
|
||||
class="f5 b" opacity="0.9" y="90%" x="40%" fill="#ffffff">{{ $output }}{{ .unit }}</text>
|
||||
</svg>
|
||||
@@ -0,0 +1,20 @@
|
||||
{{/*
|
||||
NumberFormatter
|
||||
|
||||
This partial exchanges the characters for thousends and decimals for the give integer,
|
||||
used in Germany.
|
||||
Use this for intergers and floats instead of Hugo's lang.NumFmt and float which are
|
||||
not language specific.
|
||||
|
||||
Example
|
||||
{{ partial "func/NumberFormatter.html" ( dict "number" 123456789.1234 "precision" 1 }}
|
||||
will return 123.456.789,1
|
||||
|
||||
@return String with integer
|
||||
|
||||
*/}}
|
||||
{{ $ret := strings.Replace ( lang.NumFmt .precision .number "- . ," ) "," "t" }}
|
||||
{{ $ret = strings.Replace $ret "." "d" }}
|
||||
{{ $ret = strings.Replace $ret "d" "," }}
|
||||
{{ strings.Replace $ret "t" "." }}
|
||||
|
||||
Reference in New Issue
Block a user