mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
f2b6218edc
reference issues: #312, #476
22 lines
913 B
HTML
22 lines
913 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 -}}
|
|
{{- partial "plugin/code-block-wrapper.html" . -}}
|
|
{{- end -}}
|