LoveIt/layouts/shortcodes/style.html

12 lines
671 B
HTML
Raw Normal View History

{{- $content := .Inner | .Page.RenderString -}}
2020-05-18 15:30:33 +02:00
{{- $id := dict "Scratch" .Page.Scratch | partial "function/id.html" -}}
{{- $tag := .Get 1 | default "div" -}}
2020-05-18 10:10:24 +02:00
{{- printf `<%v id="%v">%v</%v>` $tag $id $content $tag | safeHTML -}}
2020-05-18 10:10:24 +02:00
{{- $style := .Get 0 | printf "#%v{%v}" $id -}}
{{- $path := printf "style/%v/%v" (md5 .Page.RelPermalink) $id -}}
{{- $res := resources.FromString (printf "%v.scss" $path) $style -}}
{{- $res = $res | toCSS (dict "targetPath" (printf "%v.css" $path) "outputStyle" "compressed") -}}
{{- $styleArr := (.Page.Scratch.Get "this").styleArr | default slice -}}
{{- $styleArr | append $res.Content | .Page.Scratch.SetInMap "this" "styleArr" -}}