mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
⚡ Perf: optimize echarts plugin warnf content
This commit is contained in:
@@ -1,2 +1,8 @@
|
||||
{{- dict "Options" .Attributes "Inner" .Inner "Resources" .Page.Resources | partial "plugin/echarts.html" -}}
|
||||
{{- dict
|
||||
"Options" .Attributes
|
||||
"Inner" .Inner
|
||||
"Resources" .Page.Resources
|
||||
"Position" .Position
|
||||
| partial "plugin/echarts.html"
|
||||
-}}
|
||||
{{- .Page.Store.Set "hasEcharts" true -}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- .Scratch.Set "version" "v0.3.20-6eb582fe" -}}
|
||||
{{- .Scratch.Set "version" "v0.3.20-0cf0d4f4" -}}
|
||||
{{- .Scratch.Set "this" dict -}}
|
||||
|
||||
{{- partial "init/detection-env.html" . -}}
|
||||
|
||||
@@ -16,23 +16,25 @@
|
||||
{{- $content = replaceRE `[\s]+` " " $content -}}
|
||||
{{- end -}}
|
||||
{{- if not $content -}}
|
||||
{{- warnf "ECharts JS Code is empty, please check the content." -}}
|
||||
{{- warnf "ECharts: JS Code is empty, executing in file %s" $.Position -}}
|
||||
{{- end -}}
|
||||
<template data-fmt="js" data-async="{{ $async }}">{{ $content | safeJS }}</template>
|
||||
{{- else -}}
|
||||
{{ with $data }}
|
||||
{{- $content = index site.Data.echarts . -}}
|
||||
{{- if not $content -}}
|
||||
{{- warnf "ECharts data not found, please ensure the data file \"/data/echarts/%s.{json|yml|yaml|toml}\" exists." . -}}
|
||||
{{- 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." -}}
|
||||
{{- else with $file -}}
|
||||
{{- warnf "ECharts: no such data file: %s" . -}}
|
||||
{{- end -}}
|
||||
{{- $content = $content | transform.Unmarshal -}}
|
||||
{{- end -}}
|
||||
{{- if not $content -}}
|
||||
{{- warnf "ECharts: option is empty, executing in file %s" $.Position -}}
|
||||
{{- end -}}
|
||||
<template>{{ $content | jsonify }}</template>
|
||||
{{- end -}}
|
||||
|
||||
@@ -4,5 +4,11 @@
|
||||
{{- $options = .Get "async" | default false | dict "async" | merge $options -}}
|
||||
{{- $options = .Get "data" | dict "data" | merge $options -}}
|
||||
{{- $options = .Get "file" | dict "file" | merge $options -}}
|
||||
{{- dict "Options" $options "Inner" .Inner "Resources" .Page.Resources | partial "plugin/echarts.html" -}}
|
||||
{{- dict
|
||||
"Options" $options
|
||||
"Inner" .Inner
|
||||
"Resources" .Page.Resources
|
||||
"Position" .Position
|
||||
| partial "plugin/echarts.html"
|
||||
-}}
|
||||
{{- .Page.Store.Set "hasEcharts" true -}}
|
||||
|
||||
Reference in New Issue
Block a user