mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 23:38:56 +00:00
d55d53741d
> The `Param` method on a `Page` object looks for the given `KEY` in page parameters, and returns the corresponding value. If it cannot find the `KEY `in page parameters, it looks for the `KEY` in site parameters. If it cannot find the `KEY` in either location, the Param method returns `nil`. > > See: https://gohugo.io/methods/page/param/ So `.Page.Param` is only suitable for simple types.
22 lines
947 B
HTML
22 lines
947 B
HTML
{{- $jsonViewer := .Attributes | merge .Page.Params.jsonViewer | merge .Page.Site.Params.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 -}}
|