mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-25 07:48:54 +00:00
✨ Feat: add file params for echarts shortcode
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
{{- dict "Options" .Attributes "Inner" .Inner | partial "plugin/echarts.html" -}}
|
||||
{{- dict "Options" .Attributes "Inner" .Inner "Resources" .Page.Resources | partial "plugin/echarts.html" -}}
|
||||
{{- .Page.Store.Set "hasEcharts" true -}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- .Scratch.Set "version" "v0.3.20-f7a9c52a" -}}
|
||||
{{- .Scratch.Set "version" "v0.3.20-6eb582fe" -}}
|
||||
{{- .Scratch.Set "this" dict -}}
|
||||
|
||||
{{- partial "init/detection-env.html" . -}}
|
||||
|
||||
@@ -4,10 +4,14 @@
|
||||
{{- $js := .Options.js | default false -}}
|
||||
{{- $async := .Options.async | default false -}}
|
||||
{{- $data := .Options.data -}}
|
||||
{{- $file := .Options.file -}}
|
||||
{{- $attrs := printf `style="width: %v; height: %v;"` $width $height -}}
|
||||
<div class="echarts" {{ $attrs | safeHTMLAttr }}></div>
|
||||
{{- $content := strings.TrimSpace .Inner -}}
|
||||
{{- if $js -}}
|
||||
{{- if $js | or (hasSuffix $file ".js") -}}
|
||||
{{- with dict "Path" $file "Resources" .Resources | partial "function/resource.html" }}
|
||||
{{- $content = .Content -}}
|
||||
{{- end }}
|
||||
{{- if hugo.IsProduction -}}
|
||||
{{- $content = replaceRE `[\s]+` " " $content -}}
|
||||
{{- end -}}
|
||||
@@ -22,6 +26,9 @@
|
||||
{{- warnf "ECharts data not found, please ensure the data file \"/data/echarts/%s.{json|yml|yaml|toml}\" exists." . -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- with dict "Path" $file "Resources" .Resources | partial "function/resource.html" }}
|
||||
{{- $content = .Content -}}
|
||||
{{- end }}
|
||||
{{- $content = $content | transform.Unmarshal -}}
|
||||
{{- if not $content -}}
|
||||
{{- warnf "ECharts option is empty, please check the content." -}}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
{{- $options = .Get "js" | default false | dict "js" | merge $options -}}
|
||||
{{- $options = .Get "async" | default false | dict "async" | merge $options -}}
|
||||
{{- $options = .Get "data" | dict "data" | merge $options -}}
|
||||
{{- dict "Options" $options "Inner" .Inner | partial "plugin/echarts.html" -}}
|
||||
{{- $options = .Get "file" | dict "file" | merge $options -}}
|
||||
{{- dict "Options" $options "Inner" .Inner "Resources" .Page.Resources | partial "plugin/echarts.html" -}}
|
||||
{{- .Page.Store.Set "hasEcharts" true -}}
|
||||
|
||||
Reference in New Issue
Block a user