{{/* Load Preact for component-based blocks */}} {{/* Check if any blocks on this page use Preact (set by init.html) */}} {{ if .Page.Store.Get "needs_preact" }} {{ $preact_blocks := .Page.Store.Get "preact_blocks" | default slice }} {{/* Preact is now bundled with each template via js.Build and node_modules */}} {{/* Build and load each Preact block's client script */}} {{ range $block_type := $preact_blocks }} {{ $client_path := printf "js/hbx/blocks/%s/client.jsx" $block_type }} {{ $client_jsx := resources.Get $client_path }} {{ if $client_jsx }} {{/* Build the client-side JSX using Hugo's official integration */}} {{ $jsx_opts := dict "targetPath" (printf "assets/js/preact-built/%s.js" $block_type) "JSX" "automatic" "JSXImportSource" "preact" "format" "iife" "minify" hugo.IsProduction "sourceMap" (cond hugo.IsDevelopment "external" "") }} {{ $built_jsx := $client_jsx | js.Build $jsx_opts }} {{ if hugo.IsProduction }} {{ $built_jsx = $built_jsx | fingerprint "sha256" }} {{ end }} {{ end }} {{ end }} {{ end }} {{/* Load Alpine JS extension? */}} {{ if (.Page.Store.Get "has_alpine") }} {{ $alpine_js := resources.Get "dist/lib/alpinejs/cdn.min.js" }} {{ $alpine_js = $alpine_js | resources.Fingerprint "sha256" }} {{ end }} {{/* Show site search? */}} {{ $show_search := site.Params.header.navbar.show_search | default false }} {{ if $show_search }} {{ $pf_css := resources.Get "dist/pagefind/pagefind-ui.css" }} {{ $pf_css = $pf_css | resources.Fingerprint "sha256" }} {{ $pf_js := resources.Get "dist/pagefind/pagefind-ui.js" }} {{ $pf_js = $pf_js | resources.Fingerprint "sha256" }} {{ $search_config := dict "baseUrl" (relURL "") }} {{ $search_js := resources.Get "js/hb-search.js" | resources.Minify }} {{- if hugo.IsProduction -}} {{ $search_js = $search_js | fingerprint "sha256" }} {{- end -}} {{ end }} {{/* Mermaid */}} {{ if (.Page.Store.Get "has_mermaid") }} {{ $mermaid_js := resources.Get "dist/lib/mermaid/mermaid.min.js" }} {{ $mermaid_config_js := resources.Get "js/hb-mermaid-config.js" }} {{ $mermaid_config_js = $mermaid_config_js | resources.Minify }} {{ $mermaid_bundle := slice $mermaid_js $mermaid_config_js | resources.Concat "js/mermaid.bundle.js" | resources.Fingerprint "sha256" }} {{ end }} {{/* Markmap */}} {{ if (.Page.Store.Get "has_markmap") }} {{ $markmap_js := resources.Get "dist/lib/markmap/index.js" }} {{ $markmap_js = $markmap_js | resources.Minify | resources.Fingerprint "sha256" }} {{ end }} {{/* Katex */}} {{ if (.Page.HasShortcode "math") | or .Params.math | or site.Params.features.math.enable }} {{ $katex_css := resources.Get "dist/lib/katex/katex.min.css" }} {{ $katex_css = $katex_css | resources.Fingerprint "sha256" }} {{ $katex_js := resources.Get "dist/lib/katex/katex.min.js" }} {{ $katex_js = $katex_js | resources.Fingerprint "sha256" }} {{ $katex_render_js := resources.Get "dist/lib/katex/auto-render.min.js" }} {{ $katex_config_js := resources.Get "js/katex-config.js" }} {{ $katex_config_js = $katex_config_js | resources.Minify }} {{ $katex_bundle := slice $katex_render_js $katex_config_js | resources.Concat "js/katex-renderer.js" | resources.Fingerprint "sha256" }} {{ $katex_fonts := resources.Match "dist/lib/katex/fonts/*" }} {{ range $katex_fonts }} {{ .Publish }} {{ end }} {{ end }} {{/* Plotly */}} {{ if .Page.HasShortcode "chart" }} {{ $plotly_js := resources.Get "dist/lib/plotly/plotly.min.js" }} {{ $plotly_js = $plotly_js | resources.Fingerprint "sha256" }} {{ end }}