1+ #!/usr/bin/env node
2+
3+ /**
4+ * Post-processing script to fix JSDoc HTML titles
5+ * Updates "JSDoc: Home" to a more meaningful title
6+ */
7+
8+ import fs from 'fs' ;
9+ import path from 'path' ;
10+
11+ const DOCS_DIR = 'docs' ;
12+ const OLD_TITLE = 'JSDoc: Home' ;
13+ const NEW_TITLE = 'Notes API Documentation' ;
14+
15+ /**
16+ * Recursively find and update HTML files in the docs directory
17+ */
18+ function updateHTMLTitles ( dir ) {
19+ const files = fs . readdirSync ( dir ) ;
20+
21+ for ( const file of files ) {
22+ const filePath = path . join ( dir , file ) ;
23+ const stat = fs . statSync ( filePath ) ;
24+
25+ if ( stat . isDirectory ( ) ) {
26+ updateHTMLTitles ( filePath ) ;
27+ } else if ( file . endsWith ( '.html' ) ) {
28+ updateHTMLFile ( filePath ) ;
29+ }
30+ }
31+ }
32+
33+ /**
34+ * Update title in a single HTML file
35+ */
36+ function updateHTMLFile ( filePath ) {
37+ const content = fs . readFileSync ( filePath , 'utf8' ) ;
38+
39+ // Replace the title tag
40+ const updatedContent = content . replace (
41+ `<title>${ OLD_TITLE } </title>` ,
42+ `<title>${ NEW_TITLE } </title>`
43+ ) ;
44+
45+ // Also update page title heading if it's the home page
46+ const finalContent = updatedContent . replace (
47+ '<h1 class="page-title">Home</h1>' ,
48+ '<h1 class="page-title">Notes API Documentation</h1>'
49+ ) ;
50+
51+ if ( content !== finalContent ) {
52+ fs . writeFileSync ( filePath , finalContent ) ;
53+ console . log ( `✅ Updated title in ${ filePath } ` ) ;
54+ }
55+ }
56+
57+ // Run if called directly
58+ if ( import . meta. url === `file://${ process . argv [ 1 ] } ` ) {
59+ console . log ( '🔧 Fixing documentation titles...' ) ;
60+
61+ if ( ! fs . existsSync ( DOCS_DIR ) ) {
62+ console . error ( `❌ Documentation directory '${ DOCS_DIR } ' not found` ) ;
63+ process . exit ( 1 ) ;
64+ }
65+
66+ updateHTMLTitles ( DOCS_DIR ) ;
67+ console . log ( '✅ Documentation titles updated successfully' ) ;
68+ }
0 commit comments