feat(content): support complete local resource references (#388)

This commit is contained in:
Dillon
2020-05-28 17:05:37 +08:00
committed by GitHub
parent 0c1f7d0ef8
commit aa48df5edd
93 changed files with 872 additions and 714 deletions

View File

@@ -1,21 +1,22 @@
{{- $options := cond .IsNamedParams (.Get "src") (.Get 0) | dict "src" -}}
{{- $options = cond .IsNamedParams (.Get "alt") (.Get 1) | .Page.RenderString | dict "alt" | merge $options -}}
{{- $options := cond .IsNamedParams (.Get "src") (.Get 0) | dict "Src" -}}
{{- $options = cond .IsNamedParams (.Get "alt") (.Get 1) | .Page.RenderString | dict "Alt" | merge $options -}}
{{- $caption := cond .IsNamedParams (.Get "caption") (.Get 2) | .Page.RenderString -}}
{{- $options = dict "caption" $caption | merge $options -}}
{{- $options = dict "Caption" $caption | merge $options -}}
{{- if .IsNamedParams -}}
{{- $options = dict "title" (.Get "title") | merge $options -}}
{{- $options = dict "src_s" (.Get "src_s") | merge $options -}}
{{- $options = dict "src_l" (.Get "src_l") | merge $options -}}
{{- $options = dict "height" (.Get "height") | merge $options -}}
{{- $options = dict "width" (.Get "width") | merge $options -}}
{{- $options = dict "large" (.Get "large") | merge $options -}}
{{- $options = .Get "linked" | ne false | dict "linked" | merge $options -}}
{{- $options = dict "rel" (.Get "rel") | merge $options -}}
{{- $options = dict "Title" (.Get "title") | merge $options -}}
{{- $options = dict "SrcSmall" (.Get "src_s") | merge $options -}}
{{- $options = dict "SrcLarge" (.Get "src_l") | merge $options -}}
{{- $options = dict "Height" (.Get "height") | merge $options -}}
{{- $options = dict "Width" (.Get "width") | merge $options -}}
{{- $options = .Get "linked" | ne false | dict "Linked" | merge $options -}}
{{- $options = dict "Rel" (.Get "rel") | merge $options -}}
{{- else -}}
{{- $options = cond $caption true false | dict "linked" | merge $options -}}
{{- $options = cond $caption true false | dict "Linked" | merge $options -}}
{{- end -}}
{{- $options = dict "Resources" .Page.Resources | merge $options -}}
{{- with $caption -}}
<figure{{ with cond $.IsNamedParams ($.Get "class") "" }} class="{{ . }}"{{ end }}>
{{- partial "plugin/image.html" $options -}}

View File

@@ -1,11 +1,15 @@
{{- $options := cond .IsNamedParams (.Get "href") (.Get 0) | dict "href" -}}
{{- $destination := cond .IsNamedParams (.Get "href") (.Get 0) -}}
{{- with dict "Path" $destination "Resources" .Page.Resources | partial "function/resource.html" -}}
{{- $destination = .RelPermalink -}}
{{- end -}}
{{- $options := dict "Destination" $destination -}}
{{- if .IsNamedParams -}}
{{- $options = dict "content" (.Get "content") | merge $options -}}
{{- $options = dict "title" (.Get "title") | merge $options -}}
{{- $options = dict "class" (.Get "class") | merge $options -}}
{{- $options = dict "rel" (.Get "rel") | merge $options -}}
{{- $options = dict "Content" (.Get "content") | merge $options -}}
{{- $options = dict "Title" (.Get "title") | merge $options -}}
{{- $options = dict "Class" (.Get "class") | merge $options -}}
{{- $options = dict "Rel" (.Get "rel") | merge $options -}}
{{- else -}}
{{- $options = dict "content" (.Get 1 | default (.Get 0)) | merge $options -}}
{{- $options = dict "title" (.Get 2) | merge $options -}}
{{- $options = dict "Content" (.Get 1 | default (.Get 0)) | merge $options -}}
{{- $options = dict "Title" (.Get 2) | merge $options -}}
{{- end -}}
{{- partial "plugin/link.html" $options -}}

View File

@@ -2,7 +2,15 @@
{{- if .IsNamedParams -}}
{{- $theme = .Get "theme" | default $theme -}}
{{- if .Get "url" -}}
<meting-js url="{{ .Get `url` }}" name="{{ .Get `name` }}" artist="{{ .Get `artist` }}" cover="{{ .Get `cover` }}" theme="{{ $theme }}"
{{- $url := .Get "url" -}}
{{- with dict "Path" $url "Resources" .Page.Resources | partial "function/resource.html" -}}
{{- $url = .RelPermalink -}}
{{- end -}}
{{- $cover := .Get "cover" -}}
{{- with dict "Path" $cover "Resources" .Page.Resources | partial "function/resource.html" -}}
{{- $cover = .RelPermalink -}}
{{- end -}}
<meting-js url="{{ $url }}" name="{{ .Get `name` }}" artist="{{ .Get `artist` }}" cover="{{ $cover }}" theme="{{ $theme }}"
{{- with .Get "fixed" }} fixed="{{ . }}"{{ end -}}
{{- with .Get "mini" }} mini="{{ . }}"{{ end -}}
{{- with .Get "autoplay" }} autoplay="{{ . }}"{{ end -}}

View File

@@ -4,8 +4,5 @@
{{- printf `<%v id="%v">%v</%v>` $tag $id $content $tag | safeHTML -}}
{{- $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" -}}
{{- $styleArr | append $style | .Page.Scratch.SetInMap "this" "styleArr" -}}

View File

@@ -5,9 +5,9 @@
{{- $color := cond (eq $type "changed") "ff9101" "00b1ff" | cond (eq $type "deleted") "ff5252" -}}
{{- $pathTemplate := cond .Site.IsMultiLingual (printf "svg/version/%%v-%%v.%v.svg" .Page.Language.Lang) "svg/version/%v-%v.svg" -}}
{{- $path := printf $pathTemplate $version $type -}}
{{- $res := resources.Get "svg/version.template.svg" -}}
{{- $res = $res | resources.ExecuteAsTemplate $path (dict "version" $version "label" $label "color" $color) | minify -}}
{{- $resource := resources.Get "svg/version.template.svg" -}}
{{- $resource = $resource | resources.ExecuteAsTemplate $path (dict "version" $version "label" $label "color" $color) | minify -}}
{{- $alt := printf "LoveIt %v | %v" $label $version -}}
<a href="{{ $url }}" rel="noopener noreffer" target="_blank">
{{- dict "src" $res.RelPermalink "alt" $alt "class" "version" | partial "plugin/image.html" -}}
{{- dict "Src" $resource.RelPermalink "Alt" $alt "Class" "version" | partial "plugin/image.html" -}}
</a>