feat: download documentation dependencies locally for full self-hosting

Replaced CDN dependencies with local downloads for fully self-contained operation:
- Highlight.js (syntax highlighting) - 121KB
- Highlight.js GitHub Dark theme - 1.3KB
- Lunr.js (documentation search) - 29KB
- Lunr-flex (search plugin) - 43KB

Changes:
- Updated package.json postinstall to download all dependencies
- Modified docs templates to use /web/static/ paths
- Updated .gitignore to allow documentation dependencies
- Total added: ~195KB (minimal container impact)

Benefits:
-  Fully self-hosted - no external CDN requests
-  Works offline without internet access
-  No privacy/analytics leaks from CDNs
-  Consistent with project's self-hosting philosophy
-  Improved reliability for air-gapped deployments

Note: Tailwind CSS CDN remains (development-only, production uses compiled CSS)
This commit is contained in:
2026-02-02 21:22:55 -05:00
parent ed0a41e2d1
commit 0fe4a1dacc
7 changed files with 1241 additions and 11 deletions
+2 -2
View File
@@ -46,7 +46,7 @@ func DocsLayout(nav Navigation, doc Document, user User) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " - Bookhoard Documentation</title><script src=\"https://cdn.tailwindcss.com?plugins=typography\"></script><link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css\"><script src=\"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js\"></script><script src=\"https://cdn.jsdelivr.net/npm/lunr@2.3.9/lunr.min.js\"></script><script src=\"https://cdn.jsdelivr.net/npm/lunr-flex@1.0.5/lunr.flex.min.js\"></script><script>\n\t\t\t\ttailwind.config = {\n\t\t\t\t\tdarkMode: 'class',\n\t\t\t\t\ttheme: {\n\t\t\t\t\t\textend: {\n\t\t\t\t\t\t\tcolors: {\n\t\t\t\t\t\t\t\tbackground: {\n\t\t\t\t\t\t\t\t\tprimary: '#1a1b26',\n\t\t\t\t\t\t\t\t\tsecondary: '#24283b',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\ttext: {\n\t\t\t\t\t\t\t\t\tprimary: '#c0caf5',\n\t\t\t\t\t\t\t\t\tsecondary: '#9aa5ce',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tborder: '#414868',\n\t\t\t\t\t\t\t\taccent: '#7aa2f7',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttypography: ({ theme }) => ({\n\t\t\t\t\t\t\t\tinvert: {\n\t\t\t\t\t\t\t\t\tcss: {\n\t\t\t\t\t\t\t\t\t\tcode: {\n\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: theme('colors.background.primary'),\n\t\t\t\t\t\t\t\t\t\t\tcolor: theme('colors.text.primary'),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t'pre code': {\n\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: 'transparent',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tpre: {\n\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: '#14151f',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t</script></head><body class=\"bg-background-primary text-text-primary font-sans antialiased\"><!-- Mobile Menu Button --><button class=\"lg:hidden fixed top-4 left-4 z-50 bg-background-secondary border border-border rounded p-2 text-text-primary hover:bg-background-secondary/80\" onclick=\"toggleSidebar()\" aria-label=\"Toggle menu\"><svg class=\"w-6 h-6\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M4 6h16M4 12h16M4 18h16\"></path></svg></button><!-- Search Results Overlay --><div id=\"search-results\" class=\"hidden fixed inset-0 bg-black/95 z-50 overflow-y-auto p-8 transition-opacity duration-200 ease-in-out\"></div><!-- Sidebar --><div class=\"sidebar fixed left-0 top-0 bottom-0 w-72 bg-background-secondary border-r border-border overflow-y-auto z-40 lg:translate-x-0 transition-transform duration-300 ease-in-out\"><!-- Search --><div class=\"p-4 border-b border-border\"><input type=\"text\" class=\"search-input w-full px-3 py-2 rounded bg-background-primary text-text-primary border border-border focus:outline-none focus:ring-2 focus:ring-accent text-sm\" placeholder=\"Search documentation...\" id=\"docs-search\" oninput=\"searchDocs(this.value)\"></div><!-- Navigation Sections -->")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " - Bookhoard Documentation</title><script src=\"https://cdn.tailwindcss.com?plugins=typography\"></script><link rel=\"stylesheet\" href=\"/web/static/highlight-dark.min.css\"><script src=\"/web/static/highlight.min.js\"></script><script src=\"/web/static/lunr.min.js\"></script><script src=\"/web/static/lunr-flex.min.js\"></script><script>\n\t\t\t\ttailwind.config = {\n\t\t\t\t\tdarkMode: 'class',\n\t\t\t\t\ttheme: {\n\t\t\t\t\t\textend: {\n\t\t\t\t\t\t\tcolors: {\n\t\t\t\t\t\t\t\tbackground: {\n\t\t\t\t\t\t\t\t\tprimary: '#1a1b26',\n\t\t\t\t\t\t\t\t\tsecondary: '#24283b',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\ttext: {\n\t\t\t\t\t\t\t\t\tprimary: '#c0caf5',\n\t\t\t\t\t\t\t\t\tsecondary: '#9aa5ce',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tborder: '#414868',\n\t\t\t\t\t\t\t\taccent: '#7aa2f7',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttypography: ({ theme }) => ({\n\t\t\t\t\t\t\t\tinvert: {\n\t\t\t\t\t\t\t\t\tcss: {\n\t\t\t\t\t\t\t\t\t\tcode: {\n\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: theme('colors.background.primary'),\n\t\t\t\t\t\t\t\t\t\t\tcolor: theme('colors.text.primary'),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t'pre code': {\n\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: 'transparent',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tpre: {\n\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: '#14151f',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t</script></head><body class=\"bg-background-primary text-text-primary font-sans antialiased\"><!-- Mobile Menu Button --><button class=\"lg:hidden fixed top-4 left-4 z-50 bg-background-secondary border border-border rounded p-2 text-text-primary hover:bg-background-secondary/80\" onclick=\"toggleSidebar()\" aria-label=\"Toggle menu\"><svg class=\"w-6 h-6\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M4 6h16M4 12h16M4 18h16\"></path></svg></button><!-- Search Results Overlay --><div id=\"search-results\" class=\"hidden fixed inset-0 bg-black/95 z-50 overflow-y-auto p-8 transition-opacity duration-200 ease-in-out\"></div><!-- Sidebar --><div class=\"sidebar fixed left-0 top-0 bottom-0 w-72 bg-background-secondary border-r border-border overflow-y-auto z-40 lg:translate-x-0 transition-transform duration-300 ease-in-out\"><!-- Search --><div class=\"p-4 border-b border-border\"><input type=\"text\" class=\"search-input w-full px-3 py-2 rounded bg-background-primary text-text-primary border border-border focus:outline-none focus:ring-2 focus:ring-accent text-sm\" placeholder=\"Search documentation...\" id=\"docs-search\" oninput=\"searchDocs(this.value)\"></div><!-- Navigation Sections -->")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -356,7 +356,7 @@ func DocsLayoutWithExplorer(nav Navigation, doc Document, user User, explorer AP
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, " - Bookhoard Documentation</title><script src=\"https://cdn.tailwindcss.com?plugins=typography\"></script><link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css\"><script src=\"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js\"></script><script src=\"https://cdn.jsdelivr.net/npm/lunr@2.3.9/lunr.min.js\"></script><script src=\"https://cdn.jsdelivr.net/npm/lunr-flex@1.0.5/lunr.flex.min.js\"></script><script>\n\t\t\t\ttailwind.config = {\n\t\t\t\t\tdarkMode: 'class',\n\t\t\t\t\ttheme: {\n\t\t\t\t\t\textend: {\n\t\t\t\t\t\t\tcolors: {\n\t\t\t\t\t\t\t\tbackground: {\n\t\t\t\t\t\t\t\t\tprimary: '#1a1b26',\n\t\t\t\t\t\t\t\t\tsecondary: '#24283b',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\ttext: {\n\t\t\t\t\t\t\t\t\tprimary: '#c0caf5',\n\t\t\t\t\t\t\t\t\tsecondary: '#9aa5ce',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tborder: '#414868',\n\t\t\t\t\t\t\t\taccent: '#7aa2f7',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttypography: ({ theme }) => ({\n\t\t\t\t\t\t\t\tinvert: {\n\t\t\t\t\t\t\t\t\tcss: {\n\t\t\t\t\t\t\t\t\t\tcode: {\n\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: theme('colors.background.primary'),\n\t\t\t\t\t\t\t\t\t\t\tcolor: theme('colors.text.primary'),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t'pre code': {\n\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: 'transparent',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tpre: {\n\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: '#14151f',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t</script></head><body class=\"bg-background-primary text-text-primary font-sans antialiased\"><!-- Mobile Menu Button --><button class=\"lg:hidden fixed top-4 left-4 z-50 bg-background-secondary border border-border rounded p-2 text-text-primary hover:bg-background-secondary/80\" onclick=\"toggleSidebar()\" aria-label=\"Toggle menu\"><svg class=\"w-6 h-6\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M4 6h16M4 12h16M4 18h16\"></path></svg></button><!-- Search Results Overlay --><div id=\"search-results\" class=\"hidden fixed inset-0 bg-black/95 z-50 overflow-y-auto p-4 lg:p-8 transition-opacity duration-200 ease-in-out\"></div><!-- Sidebar --><div class=\"sidebar fixed left-0 top-0 bottom-0 w-72 bg-background-secondary border-r border-border overflow-y-auto z-40 lg:translate-x-0 transition-transform duration-300 ease-in-out\"><!-- Search --><div class=\"p-4 border-b border-border\"><input type=\"text\" class=\"search-input w-full px-3 py-2 rounded bg-background-primary text-text-primary border border-border focus:outline-none focus:ring-2 focus:ring-accent text-sm\" placeholder=\"Search documentation...\" id=\"docs-search\" oninput=\"searchDocs(this.value)\"></div><!-- Navigation Sections -->")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, " - Bookhoard Documentation</title><script src=\"https://cdn.tailwindcss.com?plugins=typography\"></script><link rel=\"stylesheet\" href=\"/web/static/highlight-dark.min.css\"><script src=\"/web/static/highlight.min.js\"></script><script src=\"/web/static/lunr.min.js\"></script><script src=\"/web/static/lunr-flex.min.js\"></script><script>\n\t\t\t\ttailwind.config = {\n\t\t\t\t\tdarkMode: 'class',\n\t\t\t\t\ttheme: {\n\t\t\t\t\t\textend: {\n\t\t\t\t\t\t\tcolors: {\n\t\t\t\t\t\t\t\tbackground: {\n\t\t\t\t\t\t\t\t\tprimary: '#1a1b26',\n\t\t\t\t\t\t\t\t\tsecondary: '#24283b',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\ttext: {\n\t\t\t\t\t\t\t\t\tprimary: '#c0caf5',\n\t\t\t\t\t\t\t\t\tsecondary: '#9aa5ce',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tborder: '#414868',\n\t\t\t\t\t\t\t\taccent: '#7aa2f7',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttypography: ({ theme }) => ({\n\t\t\t\t\t\t\t\tinvert: {\n\t\t\t\t\t\t\t\t\tcss: {\n\t\t\t\t\t\t\t\t\t\tcode: {\n\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: theme('colors.background.primary'),\n\t\t\t\t\t\t\t\t\t\t\tcolor: theme('colors.text.primary'),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t'pre code': {\n\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: 'transparent',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tpre: {\n\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: '#14151f',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t</script></head><body class=\"bg-background-primary text-text-primary font-sans antialiased\"><!-- Mobile Menu Button --><button class=\"lg:hidden fixed top-4 left-4 z-50 bg-background-secondary border border-border rounded p-2 text-text-primary hover:bg-background-secondary/80\" onclick=\"toggleSidebar()\" aria-label=\"Toggle menu\"><svg class=\"w-6 h-6\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M4 6h16M4 12h16M4 18h16\"></path></svg></button><!-- Search Results Overlay --><div id=\"search-results\" class=\"hidden fixed inset-0 bg-black/95 z-50 overflow-y-auto p-4 lg:p-8 transition-opacity duration-200 ease-in-out\"></div><!-- Sidebar --><div class=\"sidebar fixed left-0 top-0 bottom-0 w-72 bg-background-secondary border-r border-border overflow-y-auto z-40 lg:translate-x-0 transition-transform duration-300 ease-in-out\"><!-- Search --><div class=\"p-4 border-b border-border\"><input type=\"text\" class=\"search-input w-full px-3 py-2 rounded bg-background-primary text-text-primary border border-border focus:outline-none focus:ring-2 focus:ring-accent text-sm\" placeholder=\"Search documentation...\" id=\"docs-search\" oninput=\"searchDocs(this.value)\"></div><!-- Navigation Sections -->")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}