File tree Expand file tree Collapse file tree 9 files changed +12
-19
lines changed Expand file tree Collapse file tree 9 files changed +12
-19
lines changed Original file line number Diff line number Diff line change 33 * Uses the shared component for consistency
44 */
55
6- // Use global preact (loaded via script tag) with classic JSX transform
6+ import { render } from " preact" ;
77import { HeroBlock } from "./component.jsx" ;
88
99// Render function - immediately renders Hero components
@@ -18,7 +18,7 @@ function renderHeroBlocks() {
1818 const props = JSON . parse ( propsData ) ;
1919
2020 // Render the Preact component into the container
21- preact . render ( < HeroBlock { ...props } /> , block ) ;
21+ render ( < HeroBlock { ...props } /> , block ) ;
2222 console . debug ( `✓ Hero block "${ block . id } " rendered with Preact` ) ;
2323 } catch ( error ) {
2424 console . error ( `Failed to render Hero block "${ block . id } ":` , error ) ;
Original file line number Diff line number Diff line change 1- // Use classic JSX transform with global preact; no direct import
1+ import { h } from " preact" ;
22
33/**
44 * Icon component
Original file line number Diff line number Diff line change 33{{ if .Page.Store.Get "needs_preact" }}
44 {{ $preact_blocks := .Page.Store.Get "preact_blocks" | default slice }}
55
6- {{/* Load Preact core library */}}
7- {{ $preact_core := resources.Get "dist/lib/preact/preact.min.js" }}
8- {{ if $preact_core }}
9- {{ $preact_core = $preact_core | resources.Fingerprint "sha256" }}
10- < script src ="{{ $preact_core.RelPermalink }} " integrity ="{{ $preact_core.Data.Integrity }} "> </ script >
11-
12- {{/* Publish the source map so the browser can load it at the expected path */}}
13- {{ $preact_map := resources.Get "dist/lib/preact/preact.min.js.map" }}
14- {{ if $preact_map }}
15- {{ $preact_map.Publish }}
16- {{ end }}
17-
18- {{ end }}
6+ {{/* Preact is now bundled with each template via js.Build and node_modules */}}
197
208 {{/* Build and load each Preact block's client script */}}
219 {{ range $block_type := $preact_blocks }}
2614 {{/* Build the client-side JSX using Hugo's official integration */}}
2715 {{ $jsx_opts := dict
2816 "targetPath" (printf "assets/js/preact-built/%s.js" $block_type)
29- "JSX" "transform"
30- "JSXFactory" "preact.h"
31- "JSXFragment" "preact.Fragment"
17+ "JSX" "automatic"
18+ "JSXImportSource" "preact"
3219 "format" "iife"
3320 "minify" hugo.IsProduction
3421 "sourceMap" (cond hugo.IsDevelopment "external" "")
Original file line number Diff line number Diff line change 1111 "dependencies" : {
1212 "@tailwindcss/cli" : " ^4.1.12" ,
1313 "@tailwindcss/typography" : " ^0.5.10" ,
14+ "preact" : " ^10.27.2" ,
1415 "tailwindcss" : " ^4.1.12"
1516 }
1617}
Original file line number Diff line number Diff line change 1111 "dependencies" : {
1212 "@tailwindcss/cli" : " ^4.1.12" ,
1313 "@tailwindcss/typography" : " ^0.5.10" ,
14+ "preact" : " ^10.27.2" ,
1415 "tailwindcss" : " ^4.1.12"
1516 }
1617}
Original file line number Diff line number Diff line change 1111 "dependencies" : {
1212 "@tailwindcss/cli" : " ^4.1.12" ,
1313 "@tailwindcss/typography" : " ^0.5.10" ,
14+ "preact" : " ^10.27.2" ,
1415 "tailwindcss" : " ^4.1.12"
1516 }
1617}
Original file line number Diff line number Diff line change 1111 "dependencies" : {
1212 "@tailwindcss/cli" : " ^4.1.12" ,
1313 "@tailwindcss/typography" : " ^0.5.10" ,
14+ "preact" : " ^10.27.2" ,
1415 "tailwindcss" : " ^4.1.12"
1516 }
1617}
Original file line number Diff line number Diff line change 1111 "dependencies" : {
1212 "@tailwindcss/cli" : " ^4.1.12" ,
1313 "@tailwindcss/typography" : " ^0.5.10" ,
14+ "preact" : " ^10.27.2" ,
1415 "tailwindcss" : " ^4.1.12"
1516 }
1617}
Original file line number Diff line number Diff line change 1111 "dependencies" : {
1212 "@tailwindcss/cli" : " ^4.1.12" ,
1313 "@tailwindcss/typography" : " ^0.5.10" ,
14+ "preact" : " ^10.27.2" ,
1415 "tailwindcss" : " ^4.1.12"
1516 }
1617}
You can’t perform that action at this time.
0 commit comments