@@ -20,7 +20,7 @@ const VERSION_CONFIG = {
2020 'manage-applications' : 'manage-functions' ,
2121 // Fix define-routes links for 4.1
2222 'define-routes' : './define-routes' ,
23- '/docs/ 4.1/developers/applications/routes' : './define-routes' ,
23+ '/4.1/developers/applications/routes' : './define-routes' ,
2424 // Fix install-harperdb link
2525 './install-harperdb/index' : '../install-harperdb/' ,
2626 // Fix index link in subdirectories
@@ -639,8 +639,8 @@ function applyVersionSpecificFixes(content, filePath, version) {
639639 // Fix paths in developers/applications
640640 if ( filePath . includes ( '/developers/applications/' ) ) {
641641 // Fix relative paths to resources - use correct singular form for 4.2
642- content = content . replace ( / \/ d o c s \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ r e s o u r c e s / g, '/docs/ 4.2/technical-details/reference/resource' ) ;
643- content = content . replace ( / \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ r e s o u r c e s / g, '/docs/ 4.2/technical-details/reference/resource' ) ;
642+ content = content . replace ( / \/ d o c s \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ r e s o u r c e s / g, '/4.2/technical-details/reference/resource' ) ;
643+ content = content . replace ( / \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ r e s o u r c e s / g, '/4.2/technical-details/reference/resource' ) ;
644644 // Fix relative paths within applications
645645 content = content . replace ( / \. \. \/ \. \. \/ d e v e l o p e r s \/ a p p l i c a t i o n s \/ / g, './' ) ;
646646 content = content . replace ( / \. \. \/ d e v e l o p e r s \/ a p p l i c a t i o n s \/ / g, './' ) ;
@@ -666,19 +666,19 @@ function applyVersionSpecificFixes(content, filePath, version) {
666666 content = content . replace ( / \. \/ d e v e l o p e r s \/ a p p l i c a t i o n s \/ / g, '../applications/' ) ;
667667 content = content . replace ( / \. \. \/ \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ r e s o u r c e s / g, '../../technical-details/reference/resource' ) ;
668668 content = content . replace ( / t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ r e s o u r c e s / g, '../../technical-details/reference/resource' ) ;
669- content = content . replace ( / \/ d o c s \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ r e s o u r c e s / g, '/docs/ 4.2/technical-details/reference/resource' ) ;
670- content = content . replace ( / \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ r e s o u r c e s / g, '/docs/ 4.2/technical-details/reference/resource' ) ;
669+ content = content . replace ( / \/ d o c s \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ r e s o u r c e s / g, '/4.2/technical-details/reference/resource' ) ;
670+ content = content . replace ( / \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ r e s o u r c e s / g, '/4.2/technical-details/reference/resource' ) ;
671671 // Fix writing-extensions resource link
672672 content = content . replace ( / \. \. \/ \. \. \/ \. \. \/ r e f e r e n c e \/ r e s o u r c e / g, '../../technical-details/reference/resource' ) ;
673673 // Fix incorrect references to harperdb-cloud and harperdb-studio
674- content = content . replace ( / \. \. \/ \. \. \/ \. \. \/ h a r p e r d b - c l o u d \/ / g, '/docs/ 4.2/deployments/harperdb-cloud/' ) ;
675- content = content . replace ( / \. \. \/ \. \. \/ \. \. \/ a d m i n i s t r a t i o n \/ h a r p e r d b - s t u d i o \/ / g, '/docs/ 4.2/administration/harperdb-studio/' ) ;
674+ content = content . replace ( / \. \. \/ \. \. \/ \. \. \/ h a r p e r d b - c l o u d \/ / g, '/4.2/deployments/harperdb-cloud/' ) ;
675+ content = content . replace ( / \. \. \/ \. \. \/ \. \. \/ a d m i n i s t r a t i o n \/ h a r p e r d b - s t u d i o \/ / g, '/4.2/administration/harperdb-studio/' ) ;
676676 modified = true ;
677677 }
678678
679679 // Fix configuration links for clustering
680680 if ( filePath . includes ( '/clustering/' ) || filePath . includes ( '/security/' ) ) {
681- content = content . replace ( / \. \. \/ \. \. \/ d e v e l o p e r s \/ c o n f i g u r a t i o n / g, '/docs/ 4.2/deployments/configuration' ) ;
681+ content = content . replace ( / \. \. \/ \. \. \/ d e v e l o p e r s \/ c o n f i g u r a t i o n / g, '/4.2/deployments/configuration' ) ;
682682 modified = true ;
683683 }
684684
@@ -697,7 +697,7 @@ function applyVersionSpecificFixes(content, filePath, version) {
697697 if ( filePath . includes ( '/custom-functions/' ) ) {
698698 // Fix various define-routes patterns - the file moved to developers/applications
699699 // Use absolute paths since relative paths across sections don't work properly
700- content = content . replace ( / \] \( \. \. \/ \. \. \/ d e v e l o p e r s \/ a p p l i c a t i o n s \/ d e f i n e - r o u t e s \) / g, '](/docs/ 4.3/developers/applications/define-routes)' ) ;
700+ content = content . replace ( / \] \( \. \. \/ \. \. \/ d e v e l o p e r s \/ a p p l i c a t i o n s \/ d e f i n e - r o u t e s \) / g, '](/4.3/developers/applications/define-routes)' ) ;
701701 content = content . replace ( / \] \( d e f i n e - r o u t e s \. m d \) / g, '](../developers/applications/define-routes)' ) ;
702702 content = content . replace ( / \] \( d e f i n e - r o u t e s \) / g, '](../developers/applications/define-routes)' ) ;
703703 content = content . replace ( / \] \( \. \/ d e f i n e - r o u t e s \) / g, '](../developers/applications/define-routes)' ) ;
@@ -733,14 +733,14 @@ function applyVersionSpecificFixes(content, filePath, version) {
733733 content = content . replace ( / \. \. \/ \. \. \/ \. \. \/ r e f e r e n c e \/ r e s o u r c e \. m d / g, '../../technical-details/reference/resource' ) ;
734734 content = content . replace ( / \. \. \/ \. \. \/ \. \. \/ r e f e r e n c e \/ r e s o u r c e / g, '../../technical-details/reference/resource' ) ;
735735 // Fix incorrect references to harperdb-cloud and harperdb-studio
736- content = content . replace ( / \. \. \/ \. \. \/ \. \. \/ h a r p e r d b - c l o u d \/ / g, '/docs/ 4.3/deployments/harperdb-cloud/' ) ;
737- content = content . replace ( / \. \. \/ \. \. \/ \. \. \/ h a r p e r d b - s t u d i o \/ / g, '/docs/ 4.3/administration/harperdb-studio/' ) ;
736+ content = content . replace ( / \. \. \/ \. \. \/ \. \. \/ h a r p e r d b - c l o u d \/ / g, '/4.3/deployments/harperdb-cloud/' ) ;
737+ content = content . replace ( / \. \. \/ \. \. \/ \. \. \/ h a r p e r d b - s t u d i o \/ / g, '/4.3/administration/harperdb-studio/' ) ;
738738 modified = true ;
739739 }
740740
741741 // Fix configuration links for clustering
742742 if ( filePath . includes ( '/clustering/' ) || filePath . includes ( '/security/' ) ) {
743- content = content . replace ( / \. \. \/ \. \. \/ d e v e l o p e r s \/ c o n f i g u r a t i o n / g, '/docs/ 4.3/deployments/configuration' ) ;
743+ content = content . replace ( / \. \. \/ \. \. \/ d e v e l o p e r s \/ c o n f i g u r a t i o n / g, '/4.3/deployments/configuration' ) ;
744744 modified = true ;
745745 }
746746
@@ -752,8 +752,8 @@ function applyVersionSpecificFixes(content, filePath, version) {
752752
753753 // Fix REST configuration link - needs absolute path to stay within version
754754 if ( filePath . includes ( '/developers/rest' ) ) {
755- content = content . replace ( / \] \( \. \. \/ \. \. \/ d e p l o y m e n t s \/ c o n f i g u r a t i o n \. m d # h t t p \) / g, '](/docs/ 4.3/deployments/configuration#http)' ) ;
756- content = content . replace ( / \] \( \. \. \/ \. \. \/ d e p l o y m e n t s \/ c o n f i g u r a t i o n # h t t p \) / g, '](/docs/ 4.3/deployments/configuration#http)' ) ;
755+ content = content . replace ( / \] \( \. \. \/ \. \. \/ d e p l o y m e n t s \/ c o n f i g u r a t i o n \. m d # h t t p \) / g, '](/4.3/deployments/configuration#http)' ) ;
756+ content = content . replace ( / \] \( \. \. \/ \. \. \/ d e p l o y m e n t s \/ c o n f i g u r a t i o n # h t t p \) / g, '](/4.3/deployments/configuration#http)' ) ;
757757 modified = true ;
758758 }
759759
@@ -840,8 +840,8 @@ function applyVersionSpecificFixes(content, filePath, version) {
840840 content = content . replace ( / \] \( d e f i n i n g - s c h e m a s / g, '](../developers/applications/defining-schemas' ) ;
841841 // Fix graphql link to include version
842842 if ( filePath . includes ( '/first-harper-app' ) ) {
843- content = content . replace ( / \] \( \. \. \/ \. \. \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ g r a p h q l \. m d \) / g, '](/docs/ 4.5/technical-details/reference/graphql)' ) ;
844- content = content . replace ( / \] \( \. \. \/ \. \. \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ g r a p h q l \) / g, '](/docs/ 4.5/technical-details/reference/graphql)' ) ;
843+ content = content . replace ( / \] \( \. \. \/ \. \. \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ g r a p h q l \. m d \) / g, '](/4.5/technical-details/reference/graphql)' ) ;
844+ content = content . replace ( / \] \( \. \. \/ \. \. \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ g r a p h q l \) / g, '](/4.5/technical-details/reference/graphql)' ) ;
845845 }
846846 modified = true ;
847847 }
@@ -973,14 +973,14 @@ function applyVersionSpecificFixes(content, filePath, version) {
973973 // 4.2.0 release notes should link to 4.2 docs, 4.5.0 to 4.5 docs, etc.
974974 if ( filePath . includes ( '/4.2.0' ) ) {
975975 // Link to 4.2 docs where components directory exists (with or without trailing slash)
976- content = content . replace ( / \] \( \. \. \/ \. \. \/ \. \. \/ d e v e l o p e r s \/ c o m p o n e n t s \/ ? \) / g, '](/docs/ 4.2/developers/components)' ) ;
976+ content = content . replace ( / \] \( \. \. \/ \. \. \/ \. \. \/ d e v e l o p e r s \/ c o m p o n e n t s \/ ? \) / g, '](/4.2/developers/components)' ) ;
977977 }
978978 // For 4.5.0 release notes, fix the built-in component link
979979 // This appears in multiple versions, so we need to fix it everywhere
980980 if ( filePath . includes ( '/4.5.0' ) ) {
981981 // Replace all variations of the built-in link to point to 4.5 docs
982982 // Handle both with and without .md extension
983- content = content . replace ( / \] \( \. \. \/ \. \. \/ \. \. \/ d e v e l o p e r s \/ c o m p o n e n t s \/ b u i l t - i n (?: \. m d ) ? \) / g, '](/docs/ 4.5/developers/components/built-in)' ) ;
983+ content = content . replace ( / \] \( \. \. \/ \. \. \/ \. \. \/ d e v e l o p e r s \/ c o m p o n e n t s \/ b u i l t - i n (?: \. m d ) ? \) / g, '](/4.5/developers/components/built-in)' ) ;
984984 modified = true ;
985985 }
986986 // For older versions (4.2-4.5), the links within their own version are fine as-is
@@ -1000,20 +1000,20 @@ function applyVersionSpecificFixes(content, filePath, version) {
10001000 if ( filePath . includes ( '/4.2.0' ) ) {
10011001 // Components don't exist in 4.2 or 4.3, they were introduced in 4.6
10021002 // Update these links to point to 4.6 where the documentation actually exists
1003- content = content . replace ( / \/ d o c s \/ 4 \. 2 \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ c o m p o n e n t s \/ / g, '/docs/ 4.6/technical-details/reference/components/' ) ;
1004- content = content . replace ( / \/ d o c s \/ 4 \. 3 \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ c o m p o n e n t s \/ e x t e n s i o n s / g, '/docs/ 4.6/technical-details/reference/components/extensions' ) ;
1003+ content = content . replace ( / \/ d o c s \/ 4 \. 2 \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ c o m p o n e n t s \/ / g, '/4.6/technical-details/reference/components/' ) ;
1004+ content = content . replace ( / \/ d o c s \/ 4 \. 3 \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ c o m p o n e n t s \/ e x t e n s i o n s / g, '/4.6/technical-details/reference/components/extensions' ) ;
10051005 }
10061006
10071007 // For 4.3.0 release notes
10081008 if ( filePath . includes ( '/4.3.0' ) ) {
10091009 // harper-cli moved to deployments
1010- content = content . replace ( / \/ d o c s \/ 4 \. 3 \/ d e p l o y m e n t s \/ h a r p e r - c l i / g, '/docs/ 4.3/deployments/harperdb-cli' ) ;
1010+ content = content . replace ( / \/ d o c s \/ 4 \. 3 \/ d e p l o y m e n t s \/ h a r p e r - c l i / g, '/4.3/deployments/harperdb-cli' ) ;
10111011 }
10121012
10131013 // For 4.5.0 release notes
10141014 if ( filePath . includes ( '/4.5.0' ) ) {
10151015 // built-in-extensions doesn't exist in 4.5
1016- content = content . replace ( / \/ d o c s \/ 4 \. 5 \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ c o m p o n e n t s \/ b u i l t - i n - e x t e n s i o n s / g, '/docs/ 4.6/technical-details/reference/components/built-in-extensions' ) ;
1016+ content = content . replace ( / \/ d o c s \/ 4 \. 5 \/ t e c h n i c a l - d e t a i l s \/ r e f e r e n c e \/ c o m p o n e n t s \/ b u i l t - i n - e x t e n s i o n s / g, '/4.6/technical-details/reference/components/built-in-extensions' ) ;
10171017 }
10181018
10191019 modified = true ;
@@ -1117,7 +1117,7 @@ function processReleaseNotes(content, filePath, version) {
11171117 // Fix component links in release notes to point to the correct version
11181118 if ( filePath . includes ( '/4.2.0' ) ) {
11191119 // Link to 4.2 docs where components directory exists
1120- content = content . replace ( / \] \( \. \. \/ \. \. \/ \. \. \/ d e v e l o p e r s \/ c o m p o n e n t s \/ ? \) / g, '](/docs/ 4.2/developers/components)' ) ;
1120+ content = content . replace ( / \] \( \. \. \/ \. \. \/ \. \. \/ d e v e l o p e r s \/ c o m p o n e n t s \/ ? \) / g, '](/4.2/developers/components)' ) ;
11211121 modified = true ;
11221122 }
11231123 // The 4.5.0 built-in link fix is now handled in applyVersionSpecificFixes
@@ -1248,6 +1248,13 @@ function fixLinks(content, filePath, version) {
12481248 return match ;
12491249 } ) ;
12501250
1251+ // Remove /docs/ prefix from versioned links since routeBasePath is now '/'
1252+ // This fixes links like /docs/4.2/... to just /4.2/...
1253+ content = content . replace ( / ( \[ [ ^ \] ] + \] \( ) \/ d o c s \/ ( 4 \. [ 0 - 9 ] + \/ [ ^ ) ] + \) ) / g, ( match , prefix , versionPath ) => {
1254+ modified = true ;
1255+ return prefix + '/' + versionPath ;
1256+ } ) ;
1257+
12511258 // Also handle .md extensions in HTML links within tables (GitBook specific)
12521259 // This pattern catches href attributes in <a> tags
12531260 content = content . replace ( / ( < a \s + [ ^ > ] * h r e f = " ) ( [ ^ " ] + \. m d ) ( " ) / g, ( match , prefix , pathWithExt , suffix ) => {
0 commit comments