{{/* MapLibre GL — load before Preact block scripts so window.maplibregl is available when the map block hydrates */}} {{ if .Page.Store.Get "has_map" }} {{ $maplibre_css := resources.Get "dist/lib/maplibre/maplibre-gl.css" | resources.Fingerprint "sha256" }} {{ $maplibre_js := resources.Get "dist/lib/maplibre/maplibre-gl.js" | resources.Fingerprint "sha256" }} {{ end }} {{/* 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 }} {{/* Show site search? */}} {{ $show_search := site.Params.hugoblox.header.search | default false }} {{/* Hugo Blox Animations - load synchronously BEFORE Alpine.js to register components */}} {{ if .Page.Store.Get "has_animations" }} {{ $animations_js := resources.Get "js/hb-animations.js" | resources.Minify }} {{- if hugo.IsProduction -}} {{ $animations_js = $animations_js | fingerprint "sha256" }} {{- end -}} {{ end }} {{/* Load Alpine JS extension? */}} {{/* Alpine is needed for search modal and other interactive components */}} {{ $needs_alpine := or (.Page.Store.Get "has_alpine") $show_search (.Page.Store.Get "has_animations") }} {{ if $needs_alpine }} {{ $alpine_js := resources.Get "dist/lib/alpinejs/cdn.min.js" }} {{ $alpine_js = $alpine_js | resources.Fingerprint "sha256" }} {{ end }} {{/* Hugo Blox Search JavaScript (CSS is in main.css) */}} {{ if $show_search }} {{ $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.hugoblox.content.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 }}