fix(hugo): compatibility for Hugo basic version (#315)
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
{{- /* ID */ -}}
|
||||
{{- /* Content -> unique ID */ -}}
|
||||
{{- /* shuffle md5 as id */ -}}
|
||||
{{- $id := delimit (split (md5 now.Unix) "" | shuffle | first 6) "" | printf "id-%s" -}}
|
||||
{{- with .scratch -}}
|
||||
{{- dict $id $.content | dict "data" | dict "config" | merge (.Get "this") | .Set "this" -}}
|
||||
{{- end -}}
|
||||
{{- $count := (.scratch.Get "this").count | default 1 -}}
|
||||
{{- $id := printf "id-%d" $count -}}
|
||||
{{- $count | add 1 | .scratch.SetInMap "this" "count" -}}
|
||||
{{- dict $id .content | dict "data" | dict "config" | merge (.scratch.Get "this") | .scratch.Set "this" -}}
|
||||
{{- return $id -}}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{{- $content := .Inner | .Page.RenderString -}}
|
||||
{{- $id := dict "content" $content | partial "function/id.html" -}}
|
||||
{{- $id := dict "content" $content "scratch" .Page.Scratch | partial "function/id.html" -}}
|
||||
{{- $tag := .Get 1 | default "div" -}}
|
||||
{{- printf `<%s id="%s">%s</%s>` $tag $id $content $tag | safeHTML -}}
|
||||
|
||||
{{- $style := .Get 0 | printf "#%s{%s}" $id -}}
|
||||
{{- $res := resources.FromString (printf "temp/%s.scss" $id) $style -}}
|
||||
{{- $res = $res | toCSS (dict "targetPath" (printf "temp/%s.css" $id)) -}}
|
||||
{{- $res := resources.FromString (printf "stype/%s.scss" $id) $style -}}
|
||||
{{- $res = $res | toCSS (dict "targetPath" (printf "stype/%s.css" $id)) -}}
|
||||
{{- $styleArr := (.Page.Scratch.Get "this").styleArr | default slice -}}
|
||||
{{- $styleArr | append $res.Content | .Page.Scratch.SetInMap "this" "styleArr" -}}
|
||||
|
||||
Reference in New Issue
Block a user