@@ -153,16 +153,43 @@ export function load(app) {
153153 ) ;
154154 }
155155
156- // Inject JSON-LD before </head>
156+ // Build favicon tags with correct relative path
157+ const depth = page . url . split ( "/" ) . length - 1 ;
158+ const base = depth > 0 ? "../" . repeat ( depth ) : "./" ;
159+ const faviconTags = [
160+ `<link rel="icon" href="${ base } favicons/favicon-32x32.png" type="image/png" sizes="32x32" media="(prefers-color-scheme: light)"/>` ,
161+ `<link rel="icon" href="${ base } favicons/favicon-16x16.png" type="image/png" sizes="16x16" media="(prefers-color-scheme: light)"/>` ,
162+ `<link rel="shortcut icon" href="${ base } favicons/favicon.ico" type="image/x-icon" media="(prefers-color-scheme: light)"/>` ,
163+ `<link rel="icon" href="${ base } favicons/favicon-dark-32x32.png" type="image/png" sizes="32x32" media="(prefers-color-scheme: dark)"/>` ,
164+ `<link rel="icon" href="${ base } favicons/favicon-dark-16x16.png" type="image/png" sizes="16x16" media="(prefers-color-scheme: dark)"/>` ,
165+ `<link rel="shortcut icon" href="${ base } favicons/favicon-dark.ico" type="image/x-icon" media="(prefers-color-scheme: dark)"/>` ,
166+ `<link rel="apple-touch-icon" href="${ base } favicons/apple-touch-icon.png" type="image/png" sizes="180x180"/>` ,
167+ ] . join ( "\n" ) ;
168+
169+ // Inject JSON-LD and favicons before </head>
157170 page . contents = page . contents . replace (
158171 "</head>" ,
159- jsonLdScript + "\n</head>" ,
172+ faviconTags + "\n" + jsonLdScript + "\n</head>" ,
160173 ) ;
161174 } ) ;
162175
163- // --- Post-render: rename document files to lowercase-hyphenated slugs ---
176+ // --- Post-render: copy favicons + rename document slugs ---
164177 app . renderer . on ( Renderer . EVENT_END , ( event ) => {
165178 const outDir = event . outputDirectory ;
179+
180+ // Copy favicons to output directory
181+ const srcFavicons = path . join ( path . dirname ( outDir ) , "favicons" ) ;
182+ const destFavicons = path . join ( outDir , "favicons" ) ;
183+ if ( fs . existsSync ( srcFavicons ) ) {
184+ if ( ! fs . existsSync ( destFavicons ) ) fs . mkdirSync ( destFavicons ) ;
185+ for ( const file of fs . readdirSync ( srcFavicons ) ) {
186+ fs . copyFileSync (
187+ path . join ( srcFavicons , file ) ,
188+ path . join ( destFavicons , file ) ,
189+ ) ;
190+ }
191+ }
192+
166193 const docsDir = path . join ( outDir , "documents" ) ;
167194
168195 if ( ! fs . existsSync ( docsDir ) ) return ;
0 commit comments