fix: inline stack theme
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
{{/*
|
||||
This helper is used to generate a background color and text color from a string
|
||||
Used to generate deterministic colors for tags, categories, etc.
|
||||
*/}}
|
||||
|
||||
{{- $str := . -}}
|
||||
{{- $hash := hash.FNV32a $str -}}
|
||||
{{- $h := mod $hash 360 -}}
|
||||
|
||||
{{- $backgroundColor := printf "hsl(%d, 60%%, 84%%)" $h -}}
|
||||
{{- $textColor := printf "hsl(%d, 60%%, 15%%)" $h -}}
|
||||
|
||||
{{- return dict "BackgroundColor" $backgroundColor "TextColor" $textColor "Hue" $h -}}
|
||||
@@ -0,0 +1,29 @@
|
||||
{{- $List := index hugo.Data.external .Namespace -}}
|
||||
{{- with $List -}}
|
||||
{{- range . -}}
|
||||
{{- if eq .type "script" -}}
|
||||
<script
|
||||
src="{{ .src }}"
|
||||
{{- with .integrity -}}
|
||||
integrity="{{ . }}"
|
||||
{{- end -}}
|
||||
crossorigin="anonymous"
|
||||
{{ if .defer }}defer{{ end }}
|
||||
>
|
||||
</script>
|
||||
{{- else if eq .type "style" -}}
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="{{ .src }}"
|
||||
{{- with .integrity -}}
|
||||
integrity="{{ . }}"
|
||||
{{- end -}}
|
||||
crossorigin="anonymous"
|
||||
>
|
||||
{{- else -}}
|
||||
{{- errorf "Error: unknown external resource type: %s" .type -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- errorf "Error: external resource '%s' is not found" .Namespace -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,6 @@
|
||||
{{- $iconFile := resources.GetMatch (printf "icons/%s.svg" .) -}}
|
||||
{{- if $iconFile -}}
|
||||
{{- $iconFile.Content | safeHTML -}}
|
||||
{{- else -}}
|
||||
{{- errorf "Error: icon '%s.svg' is not found under 'assets/icons' folder" . -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,72 @@
|
||||
/// Params:
|
||||
/// Resources: Where to search for images
|
||||
/// Image: Image URL
|
||||
/// Context: page context (used to access the configuration)
|
||||
|
||||
/// Returns:
|
||||
/// Resource: Hugo image resource object
|
||||
/// Permalink: Image URL
|
||||
/// Height: Image height
|
||||
/// Width: Image width
|
||||
|
||||
{{ $result := dict }}
|
||||
|
||||
{{ if .Image }}
|
||||
{{ $url := urls.Parse .Image }}
|
||||
{{ $permalink := .Image }}
|
||||
|
||||
{{ $result = dict
|
||||
"Resource" nil
|
||||
"Permalink" $permalink
|
||||
"Height" nil
|
||||
"Width" nil
|
||||
}}
|
||||
{{ $resource := dict }}
|
||||
{{ $local := true }}
|
||||
|
||||
{{ if not (in (slice "https" "http") $url.Scheme) }}
|
||||
{{/* Local image */}}
|
||||
{{ $resource = .Resources.Get (printf "%s" (.Image | safeURL)) }}
|
||||
{{ else }}
|
||||
{{/* Remote image */}}
|
||||
{{ with try (resources.GetRemote $url (dict "timeout" .Context.Site.Params.imageProcessing.external.timeout)) }}
|
||||
{{ with .Err }}
|
||||
{{ warnf "Failed to fetch remote resource %q: %s" $url . }}
|
||||
{{ else with .Value }}
|
||||
{{ $resource = . }}
|
||||
{{ $local = false }}
|
||||
{{ else }}
|
||||
{{ warnf "Unable to get remote resource %q" $url }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ if $resource }}
|
||||
{{ if and .Context.Site.Params.imageProcessing.autoOrient (reflect.IsImageResourceProcessable $resource) }}
|
||||
{{ $filter := images.AutoOrient }}
|
||||
{{ $resource = $resource | images.Filter $filter }}
|
||||
{{ end }}
|
||||
|
||||
{{ if $local }}
|
||||
{{ $permalink = $resource.RelPermalink }}
|
||||
{{ end }}
|
||||
|
||||
{{ if reflect.IsImageResourceWithMeta $resource }}
|
||||
{{ $result = dict
|
||||
"Resource" $resource
|
||||
"Permalink" $permalink
|
||||
"Height" $resource.Height
|
||||
"Width" $resource.Width
|
||||
}}
|
||||
{{ else }}
|
||||
{{ $result = dict
|
||||
"Resource" $resource
|
||||
"Permalink" $permalink
|
||||
"Height" nil
|
||||
"Width" nil
|
||||
}}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ return $result }}
|
||||
@@ -0,0 +1,7 @@
|
||||
{{- $pages := .Pages -}}
|
||||
|
||||
{{- if eq .Context.Site.Params.SortBy "lastmod" -}}
|
||||
{{- $pages = $pages.ByLastmod.Reverse -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- return $pages -}}
|
||||
@@ -0,0 +1,16 @@
|
||||
{{- $pages := .Pages -}}
|
||||
|
||||
{{- if .IsHome -}}
|
||||
{{- $pages = where .Site.RegularPages "Type" "in" .Site.Params.mainSections -}}
|
||||
{{- else if or (eq .Kind "section") (eq .Kind "taxonomy") (eq .Kind "term") -}}
|
||||
{{- $subsections := .Sections -}}
|
||||
{{- $pages = .Pages | complement $subsections -}}
|
||||
|
||||
{{- if eq (len $pages) 0 -}}
|
||||
{{- $pages = $subsections -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $pages := partial "helper/pages-sort.html" (dict "Pages" $pages "Context" .) -}}
|
||||
|
||||
{{- return $pages -}}
|
||||
@@ -0,0 +1,8 @@
|
||||
{{- $result := slice -}}
|
||||
|
||||
{{- if or .IsHome (eq .Kind "section") (eq .Kind "taxonomy") (eq .Kind "term") -}}
|
||||
{{- $pages := partial "helper/pages.html" . -}}
|
||||
{{- $result = .Paginate $pages -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- return $result -}}
|
||||
@@ -0,0 +1,33 @@
|
||||
{{- /*
|
||||
Params:
|
||||
Resource: Hugo image resource object (Optional, for processing)
|
||||
Widths: Slice of widths to generate for srcset
|
||||
Attributes: Map of HTML attributes for the <img> tag
|
||||
*/ -}}
|
||||
|
||||
{{- $resource := .Resource -}}
|
||||
{{- $widths := .Widths -}}
|
||||
{{- $attributes := .Attributes | default dict -}}
|
||||
|
||||
{{/* Generate srcset if Resource and Widths are provided */}}
|
||||
{{- if and $widths $resource (reflect.IsImageResourceProcessable $resource) -}}
|
||||
{{- $srcset := slice -}}
|
||||
{{- range $widths -}}
|
||||
{{- if lt . $resource.Width -}}
|
||||
{{- $resized := $resource.Resize (printf "%dx" .) -}}
|
||||
{{- $srcset = $srcset | append (printf "%s %dw" $resized.RelPermalink .) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if gt (len $srcset) 0 -}}
|
||||
{{- $permalink := default $resource.RelPermalink (index $attributes "src") -}}
|
||||
{{- $srcset = $srcset | append (printf "%s %dw" $permalink $resource.Width) -}}
|
||||
{{- $attributes = merge $attributes (dict "srcset" (delimit $srcset ", ")) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
<img {{- range $k, $v := $attributes -}}
|
||||
{{- if $v -}}
|
||||
{{- printf " %s=%q" (lower $k) (printf "%v" $v) | safeHTMLAttr -}}
|
||||
{{- end -}}
|
||||
{{- end -}}>
|
||||
@@ -0,0 +1,41 @@
|
||||
{{- /*
|
||||
Params:
|
||||
Resource: Hugo image resource object (Optional, for processing)
|
||||
Width: Image width (Required)
|
||||
Height: Image height (Required)
|
||||
Resize: Whether to perform resize (Optional, default: false)
|
||||
Attributes: Map of HTML attributes for the <img> tag
|
||||
*/ -}}
|
||||
|
||||
{{- $resource := .Resource -}}
|
||||
{{- $width := .Width -}}
|
||||
{{- $height := .Height -}}
|
||||
{{- $resize := .Resize -}}
|
||||
{{- $attributes := .Attributes | default dict -}}
|
||||
|
||||
{{- if and $resize $resource (reflect.IsImageResourceProcessable $resource) $width $height -}}
|
||||
{{/* Create thumbnail with 1x/2x descriptors */}}
|
||||
{{- $srcset := slice -}}
|
||||
{{- range (slice 1 2) -}}
|
||||
{{- $w := mul $width . -}}
|
||||
{{- $h := mul $height . -}}
|
||||
{{- if and (le $w $resource.Width) (le $h $resource.Height) -}}
|
||||
{{- $resized := $resource.Fill (printf "%dx%d" $w $h) -}}
|
||||
{{- $srcset = $srcset | append (printf "%s %dx" $resized.RelPermalink .) -}}
|
||||
|
||||
{{- if eq . 1 -}}
|
||||
{{- $attributes = merge $attributes (dict "src" $resized.RelPermalink) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if gt (len $srcset) 0 -}}
|
||||
{{- $attributes = merge $attributes (dict "width" $width "height" $height "srcset" (delimit $srcset ", ")) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
<img {{- range $k, $v := $attributes -}}
|
||||
{{- if $v -}}
|
||||
{{- printf " %s=%q" (lower $k) (printf "%v" $v) | safeHTMLAttr -}}
|
||||
{{- end -}}
|
||||
{{- end -}}>
|
||||
Reference in New Issue
Block a user