mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
perf(home): disable third-party resource loading on the home page, and improve plugin comments
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
{{- /*
|
||||
Analytics script injector.
|
||||
- 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
|
||||
*/ -}}
|
||||
|
||||
{{- $analytics := .Site.Store.Get "analytics" | default dict -}}
|
||||
|
||||
{{- if $analytics.enable -}}
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
{{- /* Hook for code blocks rendering */ -}}
|
||||
{{- /*
|
||||
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
|
||||
*/ -}}
|
||||
|
||||
{{- $config := .Attributes | merge .Page.Params.codeblock | merge .Page.Site.Params.codeblock -}}
|
||||
{{- $result := transform.HighlightCodeBlock . -}}
|
||||
{{- $wrapper := $result.Wrapped -}}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
{{- /* Diagram copy button */ -}}
|
||||
{{- /*
|
||||
Copy button for diagram-like plugins.
|
||||
@param {String} [.Label] aria label text for copy action
|
||||
*/ -}}
|
||||
|
||||
{{- $label := .Label | default "Copy Diagram code" -}}
|
||||
|
||||
<button type="button" class="diagram-copy-btn" aria-label="{{ $label }}">
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
{{- /* ECharts support for code fences extended and shortcodes. */ -}}
|
||||
{{- /*
|
||||
ECharts rendering partial for code fences extended syntax and shortcode usage.
|
||||
- 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
|
||||
*/ -}}
|
||||
|
||||
{{- if ne hugo.Context.MarkupScope "home" -}}
|
||||
|
||||
{{- $width := .Options.width | default "100%" -}}
|
||||
{{- $height := .Options.height | default "30rem" -}}
|
||||
{{- $js := .Options.js | default false -}}
|
||||
@@ -42,4 +59,7 @@
|
||||
<template>{{ $content | jsonify }}</template>
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- /* EOF */ -}}
|
||||
|
||||
{{- .Page.Store.Set "hasEcharts" true -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
{{- /*
|
||||
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)
|
||||
*/ -}}
|
||||
|
||||
{{- if .Password -}}
|
||||
{{- /* Content Encryption */ -}}
|
||||
{{- $content := dict "Content" .Content "Password" .Password | partial "function/content-encryption.html" -}}
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
{{- /*
|
||||
Icon renderer for Font Awesome classes and SVG sources.
|
||||
- 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
|
||||
*/ -}}
|
||||
|
||||
{{- with .Class -}}
|
||||
<i class="{{ . }}" aria-hidden="true"></i>
|
||||
{{- else -}}
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
{{- /* Mermaid support for code fences extended and shortcodes. */ -}}
|
||||
{{- /*
|
||||
Mermaid rendering partial for code fences extended syntax and shortcode usage.
|
||||
- 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
|
||||
*/ -}}
|
||||
|
||||
{{- if ne hugo.Context.MarkupScope "home" -}}
|
||||
|
||||
{{- $code := strings.TrimSpace .Inner -}}
|
||||
{{- $wrapped := .Options.wrapper | default site.Params.mermaid.wrapper -}}
|
||||
|
||||
@@ -42,9 +55,10 @@
|
||||
<pre class="mermaid-neutral">{{ $code | safeHTML }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
{{- $codeFence | page.RenderString (dict "display" "block") -}}
|
||||
{{- $codeFence | .Page.RenderString (dict "display" "block") -}}
|
||||
</div>
|
||||
</div>
|
||||
{{- .Page.Store.Set "hasPanzoom" true -}}
|
||||
{{- else -}}
|
||||
<div class="diagram-container">
|
||||
<pre class="mermaid">{{ $code | safeHTML }}</pre>
|
||||
@@ -54,3 +68,7 @@
|
||||
<template><pre>{{ $code | safeHTML }}</pre></template>
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
{{- .Page.Store.Set "hasMermaid" true -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
{{- /*
|
||||
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
|
||||
*/ -}}
|
||||
|
||||
{{- $reward := .Reward -}}
|
||||
{{- $id := .Id -}}
|
||||
{{- $author := .Author | default "" -}}
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
{{- /*
|
||||
Script tag renderer.
|
||||
- Accepts direct script HTML or builds script source from local/remote resources.
|
||||
- Supports template execution, minify/build/fingerprint pipeline, and extra attrs.
|
||||
@param {String} .Source script source URL/path or full <script> HTML
|
||||
@param {String} [.Content] inline content to write as generated resource
|
||||
@param {String} [.Path] resource path used with Content
|
||||
@param {Object} [.Template] template name/path for ExecuteAsTemplate
|
||||
@param {Object} [.Context] template context for ExecuteAsTemplate
|
||||
@param {Boolean} [.Minify] whether to minify resource
|
||||
@param {Object} [.Build] js.Build options
|
||||
@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 "<script" -}}
|
||||
{{- safeHTML .Source -}}
|
||||
{{- else -}}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
{{- /*
|
||||
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
|
||||
*/ -}}
|
||||
|
||||
{{- $share := (partial "function/params.html").share | default dict -}}
|
||||
|
||||
{{- if $share.enable -}}
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
{{- /*
|
||||
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
|
||||
*/ -}}
|
||||
|
||||
{{- $destination := "" -}}
|
||||
{{- with .Url -}}
|
||||
{{- $destination = . | relLangURL -}}
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
{{- /*
|
||||
Stylesheet tag renderer.
|
||||
- Accepts direct <link> HTML or builds CSS resources from local paths/content.
|
||||
- Supports template execution, optional toCSS, minify/fingerprint, and preload mode.
|
||||
@param {String} .Source stylesheet URL/path or full <link> HTML
|
||||
@param {String} [.Content] inline style content to write as generated resource
|
||||
@param {String} [.Path] resource path used with Content
|
||||
@param {Object} [.Template] template name/path for ExecuteAsTemplate
|
||||
@param {Object} [.Context] template context for ExecuteAsTemplate
|
||||
@param {Object} [.ToCSS] toCSS options
|
||||
@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 "<link" -}}
|
||||
{{- safeHTML .Source -}}
|
||||
{{- else -}}
|
||||
|
||||
@@ -1,4 +1,20 @@
|
||||
{{- /* Timeline support for code fences extended and shortcodes. */ -}}
|
||||
{{- /*
|
||||
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
|
||||
*/ -}}
|
||||
|
||||
{{- $reverse := .Options.reverse | default false -}}
|
||||
{{- $placement := .Options.placement | default "bottom" -}}
|
||||
{{- $animation := .Options.animation | default false -}}
|
||||
|
||||
Reference in New Issue
Block a user