@@ -35,47 +35,23 @@ function copyMarkdownFiles() {
3535 } ) ;
3636}
3737
38- // Function to update menu links
39- function updateMenuLinks ( ) {
40- const configPath = path . join ( __dirname , '..' , 'build' , 'docs' , 'gatsby' , 'gatsby-config.js' ) ;
41-
42- // Read the config file
43- let configContent = fs . readFileSync ( configPath , 'utf8' ) ;
44-
45- // Find the menuLinks array
46- const menuLinksRegex = / m e n u L i n k s : \s * \[ ( [ \s \S ] * ?) \] / ;
47- const match = configContent . match ( menuLinksRegex ) ;
48-
49- if ( match ) {
50- // Add the new menu link
51- const newMenuLink = ` {
52- name: 'Contributors Guide',
53- link: '/making-changes',
54- ignoreNextPrev: true
55- },` ;
56-
57- // Remove the 'home' menu link and add the new one
58- const menuLinksContent = match [ 1 ]
59- . replace ( / , \s * { \s * n a m e : \s * ' h o m e ' , [ ^ } ] * } , / g, '' ) ;
60-
61- // Insert the new menu link before the closing bracket
62- const updatedContent = configContent . replace (
63- menuLinksRegex ,
64- `menuLinks: [${ newMenuLink } ${ menuLinksContent } ]`
65- ) ;
66-
67- // Write the updated content back to the file
68- fs . writeFileSync ( configPath , updatedContent ) ;
69- console . log ( 'Updated menu links in gatsby-config.js' ) ;
70- } else {
71- console . error ( 'Could not find menuLinks array in gatsby-config.js' ) ;
72- }
38+ // Function to copy Gatsby config file
39+ function copyGatsbyConfig ( ) {
40+ const sourcePath = path . join ( __dirname , '..' , 'docs' , 'config' , 'gatsby-config.js' ) ;
41+ const targetPath = path . join ( __dirname , '..' , 'build' , 'docs' , 'gatsby' , 'gatsby-config.js' ) ;
42+
43+ // Ensure target directory exists
44+ ensureDirectoryExists ( path . dirname ( targetPath ) ) ;
45+
46+ // Copy the file
47+ fs . copyFileSync ( sourcePath , targetPath ) ;
48+ console . log ( `Copied gatsby-config.js to ${ targetPath } ` ) ;
7349}
7450
7551// Execute the functions
7652try {
7753 copyMarkdownFiles ( ) ;
78- updateMenuLinks ( ) ;
54+ copyGatsbyConfig ( ) ;
7955 console . log ( 'Documentation preparation completed successfully!' ) ;
8056} catch ( error ) {
8157 console . error ( 'Error preparing documentation:' , error ) ;
0 commit comments