11import techdoc from "eleventy-plugin-techdoc" ;
22
33export default function ( eleventyConfig ) {
4- const pathPrefix = process . env . PATH_PREFIX || "/" ;
5-
64 eleventyConfig . addPlugin ( techdoc , {
75 site : {
86 name : "CommandTree" ,
@@ -20,12 +18,10 @@ export default function(eleventyConfig) {
2018 eleventyConfig . addPassthroughCopy ( "src/assets" ) ;
2119 eleventyConfig . addPassthroughCopy ( { "src/favicon.ico" : "favicon.ico" } ) ;
2220
23- // Override any favicon/icon links from plugins, then inject ours
24- const prefix = pathPrefix . endsWith ( "/" ) ? pathPrefix : pathPrefix + "/" ;
2521 const faviconLinks = [
26- ` <link rel="icon" href="${ prefix } favicon.ico" sizes="48x48">` ,
27- ` <link rel="icon" href="${ prefix } assets/images/favicon.svg" type="image/svg+xml">` ,
28- ` <link rel="apple-touch-icon" href="${ prefix } assets/images/apple-touch-icon.png">` ,
22+ ' <link rel="icon" href="/ favicon.ico" sizes="48x48">' ,
23+ ' <link rel="icon" href="/ assets/images/favicon.svg" type="image/svg+xml">' ,
24+ ' <link rel="apple-touch-icon" href="/ assets/images/apple-touch-icon.png">' ,
2925 ] . join ( "\n" ) ;
3026
3127 const isIconLink = ( line ) => {
@@ -43,40 +39,12 @@ export default function(eleventyConfig) {
4339 if ( ! this . page . outputPath ?. endsWith ( ".html" ) ) {
4440 return content ;
4541 }
46- // Strip any existing icon links (e.g. from techdoc plugin)
4742 const cleaned = content . split ( "\n" ) . filter ( l => ! isIconLink ( l ) ) . join ( "\n" ) ;
48- // Inject our favicon links
4943 return cleaned . replace ( "</head>" , faviconLinks + "\n</head>" ) ;
5044 } ) ;
5145
52- // Rewrite absolute paths for GitHub Pages subpath deployment
53- // The techdoc plugin emits hardcoded absolute paths that need the prefix
54- if ( prefix !== "/" ) {
55- const rewrites = [
56- [ 'href="/techdoc/' , `href="${ prefix } techdoc/` ] ,
57- [ 'src="/techdoc/' , `src="${ prefix } techdoc/` ] ,
58- [ 'href="/assets/' , `href="${ prefix } assets/` ] ,
59- [ 'src="/assets/' , `src="${ prefix } assets/` ] ,
60- [ 'href="/docs/' , `href="${ prefix } docs/` ] ,
61- [ 'href="/blog/' , `href="${ prefix } blog/` ] ,
62- [ 'href="/feed.xml"' , `href="${ prefix } feed.xml"` ] ,
63- [ 'href="/"' , `href="${ prefix } "` ] ,
64- ] ;
65- eleventyConfig . addTransform ( "pathprefix" , function ( content ) {
66- if ( ! this . page . outputPath ?. endsWith ( ".html" ) ) {
67- return content ;
68- }
69- let result = content ;
70- for ( const [ from , to ] of rewrites ) {
71- result = result . replaceAll ( from , to ) ;
72- }
73- return result ;
74- } ) ;
75- }
76-
7746 return {
7847 dir : { input : "src" , output : "_site" } ,
79- pathPrefix,
8048 markdownTemplateEngine : "njk" ,
8149 } ;
8250}
0 commit comments