refactor(params)!: flatten [params.page] to [params], snake_case keys, more page-level params support (#805)

* refactor(params)!: snake_case config + eliminate params.page + use .Param

BREAKING CHANGE: All params keys renamed from camelCase to snake_case,
[params.page] section eliminated (moved to [params] level), and users
must update their hugo.toml and front matter accordingly.

Key changes:
- All camelCase config keys → snake_case (e.g., defaultTheme → default_theme)
- [params.page] flat keys and sub-sections moved to [params] level
- Removed function/params.html (manual merge), replaced with Hugo .Param
- New function/param.html partial for page-level section params with
  shorthand boolean support and site defaults merging
- New function/camel-case.html for string conversion
- snake2camel.html renamed to camel-case-keys.html
- New function/get-cover.html for cover image resolution
- Deprecation warnings in detection-deprecated.html for old config keys
- Front matter only params (subtitle, featured_image, password, repost,
  weight, message) use .Params.xxx instead of .Param
- Page-level sections use param.html partial
- Simplified patch.html (siteTime only) and init/index.html

Refs: camel-case-keys.html#29 (planned v1.0 breaking change)

* refactor(params)!: move params.link to page-level, simplify link guard

- Move [params.link] and [params.link.guard] to page-level section
- link.html: .Page optional, use param.html when available for
  page-level override, fall back to site config without .Page
- Remove $guardConfig variable, use $config.guard directly
- Remove unnecessary .Page from callers that don't need page override
- friends.html: use param.html for link guard instead of link_guard

* refactor(params)!: move image/codeblock/json_viewer/filetree to page-level

- Move [params.image], [params.codeblock], [params.json_viewer],
  [params.filetree] to page-level sub-sections
- Templates use param.html for merged config (page override + site defaults)
- image.html: .Page optional, falls back to site config without .Page
- Add v1- prefix to all deprecation warnidf IDs
- Fix camelCase key access in image.html (blackList, cacheRemote)
- Fix Hugo-lowered camelCase keys in code-block-wrapper.html
- Add deprecation warnings for codeblock camelCase Markdown attributes
- Add deprecation warnings for file-tree camelCase Markdown attributes
- Update render-codeblock-toggle.html for snake_case attribute names

* style: standardize @param comment style across all HTML templates

- PascalCase types: {string} → {String}, {boolean} → {Boolean},
  {int} → {Int}, {map} → {Map}, {array} → {Array}
- Add missing ` - ` separator between param name and description
- Remove extra alignment spaces between type and param name

* refactor(params)!: move params.mermaid to page-level, extract gen/ templates

- Move [params.mermaid] to page-level sub-sections
- Mermaid config injected into window.config (per-page override support)
- mermaid.ts reads config from window.config.mermaid instead of parameter
- Create _partials/gen/ directory for JS content generators
- Move mermaid-bootstrap.html from plugin/ to gen/
- Extract window.config JS generation into gen/config.html
- mermaid.html uses param.html for wrapper config

* refactor(params)!: consolidate link_to_* into params.post_link section

- Move link_to_markdown/source/edit/report/vscode into [params.post_link]
- Rename keys: markdown, source, edit, report (bool), editor (string)
- editor defaults to "vscode", supports "trae" etc. via protocol template
- footer.html uses .Param "post_link" for all link toggles
- Remove link_to_* from deprecated keys list

* fix: add fallback for deprecated camelCase attributes and expand deprecation warnings

- render-codeblock-file-tree.html: folderSlash attribute fallback
- render-codeblock-toggle.html: lineNosToggler/lineWrapToggler fallback + warnings
- code-block-wrapper.html: maxShownLines/wrapperClass fallback
- detection-deprecated.html: add nested key warnings for 13 sections
  (header, breadcrumb, navigation, watermark, busuanzi, image, mermaid,
  codeblock, filetree, math.katex, math.mathjax.options, post_summary, footer)
- detection-deprecated.html: add link_guard front matter deprecation warning

* fix(mermaid): fix rendering in hidden tab panels and neutral layer scheduling

- isRenderContextActive: check tab-panel visibility via getBoundingClientRect
  instead of panel.hidden (tab-container uses slot-based hiding, not hidden attr)
- bindTabContainerChanged: render neutral layers when switching tabs so
  print/fallback scenarios work correctly
This commit is contained in:
Cell
2026-07-01 22:27:08 +08:00
committed by GitHub
parent bfef6c5359
commit 658f03d1e5
104 changed files with 1760 additions and 1625 deletions
+5 -5
View File
@@ -1,11 +1,11 @@
{{- /*
The extended syntax of alert is compatible with Obsidian and FixIt admonition shortcode.
@param {String} .Text the content of the admonition box
@param {String} [.Type] the type of the admonition box
@param {String} [.Title] the title of the admonition box
@param {Boolean} [.Open] whether the admonition box is open, default is true
@param {Boolean} [.Foldable] whether the admonition box is foldable, default is true
@param {String} .Text - The content of the admonition box
@param {String} [.Type] - The type of the admonition box
@param {String} [.Title] - The title of the admonition box
@param {Boolean} [.Open] - Whether the admonition box is open, default is true
@param {Boolean} [.Foldable] - Whether the admonition box is foldable, default is true
For custom admonitions, see https://fixit.lruihao.cn/documentation/content-management/shortcodes/extended/admonition/#customize-admonitions
*/ -}}
+3 -3
View File
@@ -1,8 +1,8 @@
{{- /*
The basic syntax of alert is compatible with GitHub, Obsidian, and Typora.
@param {String} .Type the type of the alert box
@param {String} .Text the content of the alert box
@param {Map} [.Attributes] the attributes of the alert box
@param {String} .Type - The type of the alert box
@param {String} .Text - The content of the alert box
@param {Map} [.Attributes] - The attributes of the alert box
@example {{- dict "Text" .Text "Type" .AlertType "Attributes" .Attributes | partial "plugin/alert.html" -}}
*/ -}}
+1 -1
View File
@@ -3,7 +3,7 @@
- Reads analytics config from Site Store.
- Conditionally renders provider snippets when enabled.
- Supported providers include Google, Fathom, Baidu, Umami, and others.
@param {Object} .Site Hugo site object
@param {Object} .Site - Hugo site object
*/ -}}
{{- $analytics := .Site.Store.Get "analytics" | default dict -}}
@@ -2,14 +2,29 @@
Code block wrapper hook for highlight output.
- Applies wrapper UI features based on codeblock config.
- Supports classic/modern modes, copy button, expand button, and line-number states.
@param {Object} .Attributes code block attributes
@param {Object} .Options code fence options
@param {String} .Inner raw code content
@param {Object} .Page current page context
@param {String} .Type language/type for current block
@param {Object} .Attributes - Code block attributes
@param {Object} .Options - Code fence options
@param {String} .Inner - Raw code content
@param {Object} .Page - Current page context
@param {String} .Type - Language/type for current block
*/ -}}
{{- $config := .Attributes | merge .Page.Params.codeblock | merge .Page.Site.Params.codeblock -}}
{{- $config := .Attributes | merge (dict "Page" .Page "Key" "codeblock" | partial "function/param.html") -}}
{{- /* Deprecated camelCase attribute support: Hugo lowercases Markdown attributes */ -}}
{{- if isset .Attributes "wrapperclass" | and (not (isset .Attributes "wrapper_class")) -}}
{{- warnidf "v1-deprecated-codeblock-attr" "The attribute `wrapperClass` is deprecated since v1.0.0, use `wrapper_class` instead. See %s" .Position -}}
{{- end -}}
{{- if isset .Attributes "maxshownlines" | and (not (isset .Attributes "max_shown_lines")) -}}
{{- warnidf "v1-deprecated-codeblock-attr" "The attribute `maxShownLines` is deprecated since v1.0.0, use `max_shown_lines` instead. See %s" .Position -}}
{{- end -}}
{{- if isset .Attributes "linenostoggler" | and (not (isset .Attributes "line_nos_toggler")) -}}
{{- warnidf "v1-deprecated-codeblock-attr" "The attribute `lineNosToggler` is deprecated since v1.0.0, use `line_nos_toggler` instead. See %s" .Position -}}
{{- end -}}
{{- if isset .Attributes "linewraptoggler" | and (not (isset .Attributes "line_wrap_toggler")) -}}
{{- warnidf "v1-deprecated-codeblock-attr" "The attribute `lineWrapToggler` is deprecated since v1.0.0, use `line_wrap_toggler` instead. See %s" .Position -}}
{{- end -}}
{{- $result := transform.HighlightCodeBlock . -}}
{{- $wrapper := $result.Wrapped -}}
@@ -17,13 +32,13 @@
{{- if $config.wrapper -}}
{{- $mode := $config.mode | default "classic" -}}
{{- $lines := cond .Inner (len (split .Inner "\n")) 0 -}}
{{- $maxShownLines := $config.maxshownlines -}}
{{- $maxShownLines := $config.max_shown_lines | default .Attributes.maxshownlines -}}
{{- $lineNoStart := cond (ne .Options.linenostart nil) .Options.linenostart 1 -}}
{{- $lineNosDigit := strings.RuneCount (sub (add $lines $lineNoStart) 1) -}}
{{- $class := "highlight" -}}
{{- with $config.class -}}{{ $class = add $class " " . }}{{- end -}}
{{- $targetClass := add "code-block " $class -}}
{{- with $config.wrapperclass -}}{{ $targetClass = add $targetClass " " . }}{{- end -}}
{{- with ($config.wrapper_class | default .Attributes.wrapperclass) -}}{{ $targetClass = add $targetClass " " . }}{{- end -}}
{{- /* Add code wrapper around the table or pre */ -}}
{{- $REin := cond (strings.Contains $wrapper `<table class="lntable">`)
@@ -49,7 +64,7 @@
{{- $wrapper = dict "Wrapper" $wrapper "Config" $config | partial "function/code-copy-btn.html" -}}
{{- end -}}
{{- /*
{{- /*
Add data attributes and class
Directly set CSS variables to ensure compatibility with non-Chromium-based browsers
See https://caniuse.com/css3-attr for attr() support status
@@ -1,6 +1,6 @@
{{- /*
Copy button for diagram-like plugins.
@param {String} [.Label] aria label text for copy action
@param {String} [.Label] - Aria label text for copy action
*/ -}}
{{- $label := .Label | default "Copy Diagram code" -}}
+9 -9
View File
@@ -3,15 +3,15 @@
- Skips rendering when MarkupScope is home.
- Supports chart options from inline content, data key, or resource file.
- Supports JavaScript template mode via js/file options.
@param {Object} [.Options] render options from shortcode or code fence attributes
@param {String} [.Options.width] chart container width (default: 100%)
@param {String} [.Options.height] chart container height (default: 30rem)
@param {Boolean} [.Options.js] whether to treat content as JS option builder
@param {Boolean} [.Options.async] whether JS template executes asynchronously
@param {String} [.Options.data] key of data source under data/echarts
@param {String} [.Options.file] local resource path for js/json/yaml/toml source
@param {String} [.Inner] inline chart option content
@param {Object} [.Page] current page context
@param {Object} [.Options] - Render options from shortcode or code fence attributes
@param {String} [.Options.width] - Chart container width (default: 100%)
@param {String} [.Options.height] - Chart container height (default: 30rem)
@param {Boolean} [.Options.js] - Whether to treat content as JS option builder
@param {Boolean} [.Options.async] - Whether JS template executes asynchronously
@param {String} [.Options.data] - Key of data source under data/echarts
@param {String} [.Options.file] - Local resource path for js/json/yaml/toml source
@param {String} [.Inner] - Inline chart option content
@param {Object} [.Page] - Current page context
*/ -}}
{{- if ne hugo.Context.MarkupScope "home" -}}
+16 -16
View File
@@ -1,11 +1,11 @@
{{- /*
Recursive function to render tree from structured data
@param {array} items - Array of tree items
@param {int} level - The expand level of the tree (expand all: -1, collapse all: 0)
@param {int} [depth=0] - Current depth level
@param {bool} [folderSlash=false] - Whether to append a trailing "/" to folder names
@param {array} [ignoreList] - List of file or folder names to ignore
@param {array} [highlightList] - List of file or folder names to highlight
@param {Array} items - Array of tree items
@param {Int} level - The expand level of the tree (expand all: -1, collapse all: 0)
@param {Int} [depth=0] - Current depth level
@param {Boolean} [folder_slash=false] - Whether to append a trailing "/" to folder names
@param {Array} [ignore_list] - List of file or folder names to ignore
@param {Array} [highlight_list] - List of file or folder names to highlight
File tree item structure:
name: string - The name of the file or folder
@@ -16,9 +16,9 @@
{{- $items := .items -}}
{{- $level := .level -}}
{{- $depth := .depth | default 0 -}}
{{- $folderSlash := .folderSlash | default false -}}
{{- $ignoreList := .ignoreList | default slice -}}
{{- $highlightList := .highlightList | default slice -}}
{{- $folderSlash := .folder_slash | default false -}}
{{- $ignoreList := .ignore_list | default slice -}}
{{- $highlightList := .highlight_list | default slice -}}
<ul class="file-tree" data-level="{{ $depth }}">
{{- /* Sort items: directories first, then files */ -}}
@@ -34,7 +34,7 @@
{{- $fileItems = $fileItems | append . -}}
{{- end -}}
{{- end -}}
{{- range (append $fileItems $dirItems) -}}
{{- $isDir := eq .type "dir" -}}
{{- $isCollapsed := $isDir | and (ge $depth $level) | and (ge $level 0) -}}
@@ -43,7 +43,7 @@
{{- if and $isDir $folderSlash -}}
{{- $label = printf "%s/" $label -}}
{{- end -}}
<li class="file-tree-item{{ if $isDir }} file-tree-folder{{ end }}{{ if $isCollapsed }} is-collapsed{{ end }}">
<span class="file-tree-label{{ if $isDir }} file-tree-toggle{{ end }}{{ if $isHighlighted }} is-highlighted{{ end }}">
{{- $icon := "file-tree-icon fa-regular " -}}
@@ -55,15 +55,15 @@
{{- dict "Class" $icon | partial "plugin/icon.html" -}}
<span class="file-tree-label__inner">{{ $label }}</span>
</span>
{{- if and $isDir .children -}}
{{- $options := dict
"items" .children
"depth" (add $depth 1)
"level" $level
"folderSlash" $folderSlash
"ignoreList" $ignoreList
"highlightList" $highlightList
"folder_slash" $folderSlash
"ignore_list" $ignoreList
"highlight_list" $highlightList
-}}
{{- template "render-file-tree" $options -}}
{{- end -}}
@@ -73,7 +73,7 @@
{{- end -}}
{{- if .items -}}
{{- $ignoreList := .ignoreList | default slice -}}
{{- $ignoreList := .ignore_list | default slice -}}
{{- $notEmpty := false -}}
{{- range .items -}}
{{- if not (in $ignoreList .name) -}}
@@ -2,11 +2,11 @@
Encrypted content renderer.
- Encrypts content payload and renders decryptor UI.
- Supports full-page mode and partial mode with isolated target container.
@param {String} .Password encryption password
@param {String} .Content content to encrypt and render
@param {String} [.Message] custom input placeholder message
@param {Boolean} [.IsPartial] whether current render is partial mode
@param {Object} [.Page] current page context (required when IsPartial is true)
@param {String} .Password - Encryption password
@param {String} .Content - Content to encrypt and render
@param {String} [.Message] - Custom input placeholder message
@param {Boolean} [.IsPartial] - Whether current render is partial mode
@param {Object} [.Page] - Current page context (required when IsPartial is true)
*/ -}}
{{- if .Password -}}
+4 -4
View File
@@ -3,10 +3,10 @@
- Renders <i> element when Class is provided.
- Resolves local SVG resources or external SVG URL fallback.
- Supports Simple Icons shorthand by icon name.
@param {String} [.Class] icon class name for <i>
@param {String} [.Src] svg source path or URL
@param {String} [.Simpleicons] simple-icons icon name
@param {String} [.Prefix] custom prefix for simple-icons source path
@param {String} [.Class] - Icon class name for <i>
@param {String} [.Src] - SVG source path or URL
@param {String} [.Simpleicons] - Simple-icons icon name
@param {String} [.Prefix] - Custom prefix for simple-icons source path
*/ -}}
{{- with .Class -}}
+49 -37
View File
@@ -1,35 +1,45 @@
{{- /*
The image plugin is a partial that handles image resources.
{{- /*
Image resource plugin.
Handles page resources, global resources, and remote images.
Supports optimisation, srcset generation, black list filtering, and remote caching.
Parameters:
- Src: The path to the image.
It can be a page resource (inside a page bundle) https://gohugo.io/methods/page/resources/
or a global resource (inside the assets directory) https://gohugo.io/functions/resources/get/
or a link to a remote resource, which can be cached if the site parameter is set https://gohugo.io/functions/resources/getremote/
- Resources: If the image is a page resource, this parameter is required. It is the .Resources of the page.
- OptimConfig: optimisation parameter, defined like
{{- $optim := slice
(dict "Process" "resize 800x Center webp q75" "descriptor" "800w")
(dict "Process" "resize 1200x Center webp q75" "descriptor" "1200w")
(dict "Process" "resize 1600x Center webp q75" "descriptor" "1600w")
-}}
See https://gohugo.io/content-management/image-processing/ for more information.
- Alt: alt text for the image. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#alt
- Height: The intrinsic height of the image, in pixels. Must be an integer without a unit.
We try to generate this value automatically if possible. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#height
- Width: The intrinsic width of the image, in pixels. Must be an integer without a unit.
We try to generate this value automatically if possible. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#width
- Loading: Indicates how the browser should load the image: eager or lazy. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#loading
- Optimise: Override the site parameter to optimise the image.
- CacheRemote: Override the site parameter to cache remote images.
- BlackList: A list of image file names or patterns to exclude from optimisation, default is from site parameter.
- Matches: If the image is a page resource, this parameter can help to find the resource by names. e.g. ["featured-image", "featured-image-preview"].
Pass .Page when the caller needs page-level config override (e.g., content images).
Omit .Page for decorative/site-level images (e.g., logos, avatars, badges).
Thanks @HEIGE-PCloud for the original code in the DoIt theme.
https://github.com/HEIGE-PCloud/DoIt/blob/main/layouts/_partials/plugin/image.html
@param {String} .Src - Image path (page resource, global resource, or remote URL)
@param {Object} [.Resources] - Page resources (.Resources), required for page resources
@param {Array} [.OptimConfig] - srcset processing config, e.g.:
slice (dict "Process" "resize 800x webp" "descriptor" "800w")
See https://gohugo.io/content-management/image-processing/
@param {String} [.Alt] - Alt text
@param {String} [.Title] - Title attribute
@param {String} [.Caption] - Caption for lightgallery
@param {Int} [.Width] - Intrinsic width in pixels
@param {Int} [.Height] - Intrinsic height in pixels
@param {String} [.Loading] - "eager" or "lazy" (default: "lazy")
@param {String} [.Class] - CSS classes
@param {String} [.Sizes] - srcset sizes attribute
@param {Array} [.Matches] - Resource match names, e.g. ["featured-image-preview", "featured-image"]
@param {Boolean} [.Linked] - Wrap in lightgallery link
@param {Object} [.Rel] - rel attribute
@param {String} [.Decoding] - decoding attribute
@param {String} [.Referrerpolicy] - referrerpolicy attribute
@param {Boolean} [.Optimise] - Override site param to enable optimisation
@param {Boolean} [.CacheRemote] - Override site param to enable remote caching
@param {Array} [.BlackList] - Override site param black list
@param {Object} [.Page] - Page context for page-level image config override
@example
{{- dict "Src" "cover.jpg" "Resources" .Resources | partial "plugin/image.html" -}}
{{- dict "Src" "logo.png" "Class" "logo" "Width" 32 "Height" 32 | partial "plugin/image.html" -}}
Thanks @HEIGE-PCloud for the original code in the DoIt theme.
*/ -}}
{{- $config := site.Params.image -}}
{{- $config := partial "function/camel-case-keys.html" site.Params.image -}}
{{- with .Page -}}
{{- $config = dict "Page" . "Key" "image" "ToCamel" true | partial "function/param.html" -}}
{{- end -}}
{{- $Resources := .Resources | default page.Resources -}}
{{- $isInline := strings.HasPrefix .Src "data:image" -}}
{{- $isRemote := urls.Parse .Src | partial "function/is-url-remote.html" -}}
@@ -47,14 +57,6 @@ https://github.com/HEIGE-PCloud/DoIt/blob/main/layouts/_partials/plugin/image.ht
{{- $resource = $resource | default ($Resources.Get .Src) | default (resources.Get .Src) -}}
{{- end -}}
{{- /* Get remote image resource */ -}}
{{- $cacheRemote := .CacheRemote | default $config.cacheRemote | default false -}}
{{- if not $resource | and $cacheRemote -}}
{{- with partial "function/get-remote-image.html" (dict "Src" .Src) -}}
{{- $resource = . -}}
{{- end -}}
{{- end -}}
{{- /* Check if the image is blocked from optimisation */ -}}
{{- $blackList := .BlackList | default $config.blackList | default slice -}}
{{- $isBlocked := false -}}
@@ -63,12 +65,22 @@ https://github.com/HEIGE-PCloud/DoIt/blob/main/layouts/_partials/plugin/image.ht
{{- with $blackList -}}
{{- $regex = replace (delimit . "|") "." "\\." -}}
{{- $regex = replace $regex "*" ".*" -}}
{{- $isBlocked = gt (findRE $regex $.Src | len) 0 -}}
{{- end -}}
{{- /* Get remote image resource (skip if blocked by black_list) */ -}}
{{- $cacheRemote := .CacheRemote | default $config.cacheRemote | default false -}}
{{- if not $resource | and $cacheRemote | and (not $isBlocked) -}}
{{- with partial "function/get-remote-image.html" (dict "Src" .Src) -}}
{{- $resource = . -}}
{{- end -}}
{{- end -}}
{{- /* raster graphics */ -}}
{{- $rasterTypes := slice "svg" "avif" -}}
{{- $isRaster := false -}}
{{- if $resource -}}
{{- if $regex -}}
{{- if $regex | and (not $isBlocked) -}}
{{- $isBlocked = gt (findRE $regex $resource.Name | len) 0 -}}
{{- end -}}
{{- if not $isBlocked -}}
+21 -26
View File
@@ -3,20 +3,20 @@
- Auto-detects external links and applies target/rel policies.
- Supports optional icon, download hint, and external icon display.
- Supports card mode with URL meta and favicon fallback.
@param {String} .Destination target URL
@param {String} [.Content] link label HTML
@param {String} [.Title] title attribute
@param {String} [.Class] custom CSS classes
@param {String} [.Rel] rel attribute value
@param {Boolean} [.Newtab] force external behavior
@param {Boolean} [.Noreferrer] whether to include noreferrer (default: true)
@param {Boolean} [.ExternalIcon] whether to show external-link icon
@param {Object} [.Icon] icon params for plugin/icon.html
@param {Boolean} [.Card] whether to render card link layout
@param {String} [.CardIcon] card icon URL or icon class
@param {String} [.Download] download attribute value
@param {Boolean} [.IsGuarded] explicitly enable or disable link guard
@param {Object} [.Page] current page context
@param {String} .Destination - Target URL
@param {String} [.Content] - Link label HTML
@param {String} [.Title] - Title attribute
@param {String} [.Class] - Custom CSS classes
@param {String} [.Rel] - Rel attribute value
@param {Boolean} [.Newtab] - Force external behavior
@param {Boolean} [.Noreferrer] - Whether to include noreferrer (default: true)
@param {Boolean} [.ExternalIcon] - Whether to show external-link icon
@param {Object} [.Icon] - Icon params for plugin/icon.html
@param {Boolean} [.Card] - Whether to render card link layout
@param {String} [.CardIcon] - Card icon URL or icon class
@param {String} [.Download] - Download attribute value
@param {Boolean} [.IsGuarded] - Explicitly enable or disable link guard
@param {Object} [.Page] - Page context for page-level link config override
*/ -}}
{{- /* Regular link rendering */ -}}
@@ -102,7 +102,10 @@
{{- end -}}
{{- $blockSchemes := slice "javascript" "mailto" "tel" "file" "data" "vscode" "trae" -}}
{{- $config := partial "function/snake2camel.html" site.Params.link -}}
{{- $config := partial "function/camel-case-keys.html" site.Params.link -}}
{{- with .Page -}}
{{- $config = dict "Page" . "Key" "link" "ToCamel" true | partial "function/param.html" -}}
{{- end -}}
{{- $rel := .Rel | default "" -}}
{{- $isExternal := false -}}
{{- $noreferrer := true -}}
@@ -126,18 +129,10 @@
{{- /* External link guard */ -}}
{{- $isGuarded := false -}}
{{- $guardConfig := $config.guard -}}
{{- with .Page.Params.link_guard -}}
{{- if reflect.IsMap . -}}
{{- $guardConfig = (partial "function/snake2camel.html" .) | merge $guardConfig -}}
{{- else -}}
{{- $guardConfig = (dict "enable" .) | merge $guardConfig -}}
{{- end -}}
{{- end -}}
{{- if
$guardConfig.enable
$config.guard.enable
| and $isExternal
| and (not (in $guardConfig.allowDomains $url.Host))
| and (not (in $config.guard.allowDomains $url.Host))
-}}
{{- $isGuarded = .IsGuarded | default true -}}
{{- end -}}
@@ -159,7 +154,7 @@
{{- with .Download -}}
{{- $attrs = printf ` download="%s"` . | add $attrs -}}
{{- end -}}
{{- if $isGuarded | and (eq $guardConfig.mode "modal") -}}
{{- if $isGuarded | and (eq $config.guard.mode "modal") -}}
{{- $attrs = add $attrs ` data-guard="modal"` -}}
{{- end -}}
@@ -1,32 +0,0 @@
{{- /*
Mermaid bootstrap script generator.
Returns inline module JS source used by store/script.html.
@param {String} .MermaidModuleURL
@param {String} .MermaidCDN
@param {String} .ZenumlCDN
@param {Array} .LayoutLoaders
@param {Object} .Mermaid
*/ -}}
{{- printf `/** Mermaid bootstrap script generator. */
import { bootstrapMermaid } from %s
const mermaidSource = %s
const zenumlSource = %s
const layoutLoaderSources = %s
const mermaidConfig = %s
void bootstrapMermaid({
mermaidSource,
zenumlSource,
layoutLoaderSources,
config: mermaidConfig,
})
`
(.MermaidModuleURL | jsonify)
(.MermaidCDN | jsonify)
(.ZenumlCDN | jsonify)
(.LayoutLoaders | jsonify)
(.Mermaid | jsonify)
-}}
+7 -6
View File
@@ -3,17 +3,18 @@
- Skips rendering when MarkupScope is home.
- Supports wrapped view with tabs/actions and plain diagram mode.
- Supports per-diagram filename for code/download actions.
@param {Object} [.Options] render options from shortcode or code fence attributes
@param {Boolean} [.Options.wrapper] whether to enable wrapped diagram UI
@param {String} [.Options.filename] filename used by diagram/code actions
@param {String} [.Inner] inline Mermaid source content
@param {Object} [.Page] current page context
@param {Object} [.Options] - Render options from shortcode or code fence attributes
@param {Boolean} [.Options.wrapper] - Whether to enable wrapped diagram UI
@param {String} [.Options.filename] - Filename used by diagram/code actions
@param {String} [.Inner] - Inline Mermaid source content
@param {Object} [.Page] - Current page context
*/ -}}
{{- if ne hugo.Context.MarkupScope "home" -}}
{{- $code := strings.TrimSpace .Inner -}}
{{- $wrapped := .Options.wrapper | default site.Params.mermaid.wrapper -}}
{{- $mermaidConfig := dict "Page" .Page "Key" "mermaid" | partial "function/param.html" -}}
{{- $wrapped := .Options.wrapper | default $mermaidConfig.wrapper -}}
{{- if $wrapped -}}
{{- $labelDiagram := T "tabs.diagram" -}}
@@ -1,11 +1,8 @@
{{- if and .Site.Params.search.enable (eq .Site.Params.search.type "pagefind") .IsPage -}}
{{- $params := partial "function/params.html" -}}
{{- $hidden := cond (eq $params.hiddenFromSearch true) "true" "false" -}}
{{- $encrypted := cond (and (isset $params "password") (ne (printf "%v" $params.password) "")) "true" "false" -}}
{{- $pageDate := (.PublishDate | default .Date) -}}
{{- $dateLabel := $pageDate | dateFormat (.Site.Params.dateFormat | default "2006-01-02") -}}
<meta data-pagefind-filter="hidden:{{ $hidden }}">
<meta data-pagefind-filter="encrypted:{{ $encrypted }}">
{{- $dateLabel := $pageDate | dateFormat (.Site.Params.date_format | default "2006-01-02") -}}
<meta data-pagefind-filter="hidden:{{ string (.Param `hidden_from_search`) }}">
<meta data-pagefind-filter="encrypted:{{ string (.Params.password | not | not) }}">
<meta data-pagefind-sort="date:{{ $pageDate.Unix }}">
<meta data-pagefind-sort="title:{{ .Title }}">
<meta data-pagefind-meta="date:{{ $dateLabel }}">
+3 -24
View File
@@ -5,7 +5,7 @@
Podcast: https://ai.zhheo.com/docs/podcast.html
TODO refactor and migrate to theme component
*/ -}}
{{- $params := .Params | merge .Site.Params -}}
{{- $params := .Params | merge .Site.Params | partial "function/camel-case-keys.html" -}}
{{- $chatConfig := $params.postChat -}}
{{- $summaryConfig := $params.postSummary -}}
{{- $podcastConfig := $params.podcast -}}
@@ -17,7 +17,7 @@
"both" "postChatUser_summary.min.js"
-}}
{{- /* PostSummary only for public posts */ -}}
{{- $password := .Params.password | default .Site.Params.page.password -}}
{{- $password := .Params.password -}}
{{- $isPost := (eq .Kind "page") | and (eq .Type "posts") | and (not $password) -}}
{{- $summaryEnable := cond $isPost $summaryConfig.enable false -}}
{{- $enable := $chatConfig.enable | or $summaryEnable -}}
@@ -81,28 +81,7 @@
{{- $blackDom = $blackDom | append . -}}
{{- end -}}
{{- $upLoadWeb := cond (.IsHome | or $password | or (eq .Kind "404")) false $chatConfig.upLoadWeb -}}
{{- $postChatConfig := dict
"userMode" $chatConfig.userMode
"defaultInput" $chatConfig.defaultInput
"left" $chatConfig.left
"bottom" $chatConfig.bottom
"width" $chatConfig.width
"height" $chatConfig.height
"fill" $chatConfig.fill
"backgroundColor" $chatConfig.backgroundColor
"upLoadWeb" $upLoadWeb
"showInviteLink" $chatConfig.showInviteLink
"userTitle" $chatConfig.userTitle
"userDesc" $chatConfig.userDesc
"addButton" $chatConfig.addButton
"blackDom" $blackDom
"frameWidth" $chatConfig.frameWidth
"frameHeight" $chatConfig.frameHeight
"userIcon" $chatConfig.userIcon
"defaultChatQuestions" $chatConfig.defaultChatQuestions
"defaultSearchQuestions" $chatConfig.defaultSearchQuestions
"hotWords" $chatConfig.hotWords
-}}
{{- $postChatConfig := dict "upLoadWeb" $upLoadWeb "blackDom" $blackDom | merge $chatConfig -}}
{{- $configJS = add $configJS ($postChatConfig | jsonify | printf "var postChatConfig=%s") -}}
{{- end -}}
+3 -3
View File
@@ -2,9 +2,9 @@
Post reward panel renderer.
- Renders reward switch button and reward QR/payment images.
- Supports optional author prefix and animation mode.
@param {Object} .Reward reward config object
@param {String} .Id unique input id for reward toggle
@param {String} [.Author] optional author name for image alt text
@param {Object} .Reward - Reward config object
@param {String} .Id - Unique input id for reward toggle
@param {String} [.Author] - Optional author name for image alt text
*/ -}}
{{- $reward := .Reward -}}
+14 -14
View File
@@ -2,20 +2,20 @@
Script tag renderer.
- Accepts direct script HTML, a pre-built resource, or builds from source path.
- Supports template execution, minify/build/fingerprint pipeline, and extra attrs.
@param {String} [.Source] script source URL/path; if starts with "<script" it's treated as raw HTML
@param {resource.Resource} [.Resource] pre-built resource (skips build pipeline)
@param {String} [.Content] inline content to write as generated resource
@param {String} [.Path] target path for resource created from Content
@param {Object} [.Template] target path for resource created from template execution
@param {Object} [.Context] template context for ExecuteAsTemplate
@param {Boolean} [.Minify] whether to minify resource
@param {Object} [.Build] js.Build options (Build.minify is normalized to .Minify for path semantics)
@param {String} [.Fingerprint] fingerprint algorithm
@param {Boolean} [.Async] whether to add async attribute
@param {Boolean} [.Defer] whether to add defer attribute
@param {Boolean} [.Crossorigin] whether to add crossorigin=anonymous
@param {String} [.Integrity] SRI hash value
@param {String} [.Attr] additional attributes
@param {String} [.Source] - Script source URL/path; if starts with "<script" it's treated as raw HTML
@param {resource.Resource} [.Resource] - Pre-built resource (skips build pipeline)
@param {String} [.Content] - Inline content to write as generated resource
@param {String} [.Path] - Target path for resource created from Content
@param {Object} [.Template] - Target path for resource created from template execution
@param {Object} [.Context] - Template context for ExecuteAsTemplate
@param {Boolean} [.Minify] - Whether to minify resource
@param {Object} [.Build] - js.Build options (Build.minify is normalized to .Minify for path semantics)
@param {String} [.Fingerprint] - Fingerprint algorithm
@param {Boolean} [.Async] - Whether to add async attribute
@param {Boolean} [.Defer] - Whether to add defer attribute
@param {Boolean} [.Crossorigin] - Whether to add crossorigin=anonymous
@param {String} [.Integrity] - SRI hash value
@param {String} [.Attr] - Additional attributes
*/ -}}
{{- if strings.HasPrefix (.Source | default "") "<script" -}}
+8 -7
View File
@@ -2,13 +2,14 @@
Social share buttons renderer.
- Reads share switches from merged theme/page params.
- Outputs provider-specific sharer attributes for supported platforms.
@param {Object} .Page current page context
@param {Object} .Page - Current page context
*/ -}}
{{- $share := (partial "function/params.html").share | default dict -}}
{{- $share := dict "Page" . "Key" "share" | partial "function/param.html" | default dict -}}
{{- if $share.enable -}}
{{- $title := cond (.Param "capitalizeTitles") (title .Title) .Title -}}
{{- $title := cond (.Param "capitalize_titles") (title .Title) .Title -}}
{{- $cover := dict "Page" . "Preview" true "Build" true | partial "function/get-cover.html" -}}
{{- $twitterVia := "" -}}
{{- with .Site.Params.social.twitter -}}
{{- if reflect.IsMap . -}}
@@ -54,7 +55,7 @@
{{- /* 006: Pinterest */ -}}
{{- if $share.Pinterest -}}
<a href="javascript:void(0);" title="{{ T `shareOn` }} Pinterest" data-sharer="pinterest" data-url="{{ .Permalink }}"{{ with .Description }} data-description="{{ . }}"{{ end }}{{ with .Params.featuredImage }} data-image="{{ . }}"{{ end }}>
<a href="javascript:void(0);" title="{{ T `shareOn` }} Pinterest" data-sharer="pinterest" data-url="{{ .Permalink }}"{{ with .Description }} data-description="{{ . }}"{{ end }}{{ with $cover.URL }} data-image="{{ . }}"{{ end }}>
{{- dict "Class" "fa-brands fa-pinterest" | partial "plugin/icon.html" -}}
</a>
{{ end -}}
@@ -82,14 +83,14 @@
{{- /* 010: VK */ -}}
{{- if $share.VK -}}
<a href="javascript:void(0);" title="{{ T `shareOn` }} VK" data-sharer="vk" data-url="{{ .Permalink }}" data-title="{{ $title }}"{{ with .Description }} data-caption="{{ . }}"{{ end }}{{ with .Params.featuredImage }} data-image="{{ . }}"{{ end }}>
<a href="javascript:void(0);" title="{{ T `shareOn` }} VK" data-sharer="vk" data-url="{{ .Permalink }}" data-title="{{ $title }}"{{ with .Description }} data-caption="{{ . }}"{{ end }}{{ with $cover.URL }} data-image="{{ . }}"{{ end }}>
{{- dict "Class" "fa-brands fa-vk" | partial "plugin/icon.html" -}}
</a>
{{ end -}}
{{- /* 011: Buffer */ -}}
{{- if $share.Buffer -}}
<a href="javascript:void(0);" title="{{ T `shareOn` }} Buffer" data-sharer="buffer" data-url="{{ .Permalink }}" data-title="{{ $title }}"{{ with $twitterVia }} data-via="{{ strings.TrimPrefix `@` . }}"{{ end }}{{ with .Params.featuredImage }} data-picture="{{ . }}"{{ end }}>
<a href="javascript:void(0);" title="{{ T `shareOn` }} Buffer" data-sharer="buffer" data-url="{{ .Permalink }}" data-title="{{ $title }}"{{ with $twitterVia }} data-via="{{ strings.TrimPrefix `@` . }}"{{ end }}{{ with $cover.URL }} data-picture="{{ . }}"{{ end }}>
{{- dict "Class" "fa-brands fa-buffer" | partial "plugin/icon.html" -}}
</a>
{{ end -}}
@@ -131,7 +132,7 @@
{{- /* 017: 微博 */ -}}
{{- if $share.Weibo -}}
<a href="javascript:void(0);" title="{{ T `shareOn` }} 微博" data-sharer="weibo" data-url="{{ .Permalink }}" data-title="{{ $title }}"{{ with .Params.featuredImage }} data-image="{{ . }}"{{ end }}{{ with .Site.Params.Social.Weibo }} data-ralateuid="{{ . }}"{{ end }}>
<a href="javascript:void(0);" title="{{ T `shareOn` }} 微博" data-sharer="weibo" data-url="{{ .Permalink }}" data-title="{{ $title }}"{{ with $cover.URL }} data-image="{{ . }}"{{ end }}{{ with .Site.Params.Social.Weibo }} data-ralateuid="{{ . }}"{{ end }}>
{{- dict "Class" "fa-brands fa-weibo" | partial "plugin/icon.html" -}}
</a>
{{ end -}}
+4 -4
View File
@@ -2,10 +2,10 @@
Social profile link helper.
- Builds destination from explicit Url or from Prefix/Template/Id.
- Delegates final rendering to plugin/link.html with rel=me.
@param {String} [.Url] explicit target URL
@param {String} [.Template] URL template containing one %%v placeholder
@param {String} [.Prefix] URL prefix used to build Template
@param {String} [.Id] account id used by Template
@param {String} [.Url] - Explicit target URL
@param {String} [.Template] - URL template containing one %%v placeholder
@param {String} [.Prefix] - URL prefix used to build Template
@param {String} [.Id] - Account id used by Template
*/ -}}
{{- $destination := "" -}}
+13 -13
View File
@@ -2,19 +2,19 @@
Stylesheet tag renderer.
- Accepts direct <link> HTML, a pre-built resource, or builds from source path.
- Supports template execution, optional toCSS, minify/fingerprint, and preload mode.
@param {String} [.Source] stylesheet URL/path; if starts with "<link" it's treated as raw HTML
@param {resource.Resource} [.Resource] pre-built resource (skips build pipeline)
@param {String} [.Content] inline style content to write as generated resource
@param {String} [.Path] target path for resource created from Content
@param {Object} [.Template] target path for resource created from template execution
@param {Object} [.Context] template context for ExecuteAsTemplate
@param {Object|Boolean} [.ToCSS] true for defaults, dict for custom toCSS options, false/omit to skip toCSS
@param {Boolean} [.Minify] whether to minify resource
@param {String} [.Fingerprint] fingerprint algorithm
@param {Boolean} [.Crossorigin] whether to add crossorigin=anonymous
@param {Boolean} [.Preload] whether to output preload + noscript fallback
@param {String} [.Integrity] SRI hash value
@param {String} [.Attr] additional attributes
@param {String} [.Source] - Stylesheet URL/path; if starts with "<link" it's treated as raw HTML
@param {resource.Resource} [.Resource] - Pre-built resource (skips build pipeline)
@param {String} [.Content] - Inline style content to write as generated resource
@param {String} [.Path] - Target path for resource created from Content
@param {Object} [.Template] - Target path for resource created from template execution
@param {Object} [.Context] - Template context for ExecuteAsTemplate
@param {Object|Boolean} [.ToCSS] - True for defaults, dict for custom toCSS options, false/omit to skip toCSS
@param {Boolean} [.Minify] - Whether to minify resource
@param {String} [.Fingerprint] - Fingerprint algorithm
@param {Boolean} [.Crossorigin] - Whether to add crossorigin=anonymous
@param {Boolean} [.Preload] - Whether to output preload + noscript fallback
@param {String} [.Integrity] - SRI hash value
@param {String} [.Attr] - Additional attributes
*/ -}}
{{- if strings.HasPrefix (.Source | default "") "<link" -}}
+11 -11
View File
@@ -2,17 +2,17 @@
Timeline rendering partial for code fences extended syntax and shortcode usage.
- Supports events from inline content, data key, resource file, or direct Events input.
- Supports reverse order, placement, animation, node style, and size options.
@param {Object} [.Options] render options from shortcode or code fence attributes
@param {Boolean} [.Options.reverse] whether to sort events in descending order
@param {String} [.Options.placement] default timestamp placement
@param {Boolean} [.Options.animation] whether to enable item animation
@param {String} [.Options.size] timeline size variant
@param {String} [.Options.node] timeline node style
@param {String} [.Options.data] key of data source under data/timeline
@param {String} [.Options.file] local resource path for timeline data
@param {String} [.Inner] inline timeline source content
@param {Array} [.Events] direct events array override
@param {Object} [.Page] current page context
@param {Object} [.Options] - Render options from shortcode or code fence attributes
@param {Boolean} [.Options.reverse] - Whether to sort events in descending order
@param {String} [.Options.placement] - Default timestamp placement
@param {Boolean} [.Options.animation] - Whether to enable item animation
@param {String} [.Options.size] - Timeline size variant
@param {String} [.Options.node] - Timeline node style
@param {String} [.Options.data] - Key of data source under data/timeline
@param {String} [.Options.file] - Local resource path for timeline data
@param {String} [.Inner] - Inline timeline source content
@param {Array} [.Events] - Direct events array override
@param {Object} [.Page] - Current page context
*/ -}}
{{- $reverse := .Options.reverse | default false -}}