mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-25 07:48:54 +00:00
fa94e69877
* feat: add JSON Viewer support and related configurations * feat: add JSON Viewer initialization and theme switching support
23 lines
938 B
HTML
23 lines
938 B
HTML
{{- $jsonViewer := .Attributes | merge (.Page.Param "jsonViewer") -}}
|
|
{{- if $jsonViewer.enable -}}
|
|
{{- $attrs := printf `expand-depth="%v"` $jsonViewer.expanddepth -}}
|
|
{{- $copyable := false -}}
|
|
{{- with $jsonViewer.copyable -}}
|
|
{{- $copyable = dict "copyText" (T "assets.copyText") "copiedText" (T "assets.copiedText") -}}
|
|
{{- end -}}
|
|
{{- with $jsonViewer.sort -}}
|
|
{{- $attrs = " sort" | add $attrs -}}
|
|
{{- end -}}
|
|
{{- with $jsonViewer.boxed -}}
|
|
{{- $attrs = " boxed" | add $attrs -}}
|
|
{{- end -}}
|
|
<json-viewer value="{{ .Inner | jsonify }}" {{ $attrs | safeHTMLAttr }}{{ with $copyable}} copyable="{{ . | jsonify }}"{{ end }}></json-viewer>
|
|
{{- .Page.Store.Set "hasJsonViewer" true -}}
|
|
{{- if eq hugo.Context.MarkupScope "home" -}}
|
|
{{- site.Home.Store.Set "hasJsonViewer" true -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- $result := transform.HighlightCodeBlock . -}}
|
|
{{- $result.Wrapped -}}
|
|
{{- end -}}
|