@@ -3,7 +3,7 @@ import { glob } from 'glob';
33import matter from 'gray-matter' ;
44import fs from 'fs' ;
55import path from 'path' ;
6- import { createSinglePageDocumentation , generateAllToggleSinglePages } from '../generate-single-page.ts' ;
6+ import { createSinglePageToggleDocumentation , generateAllToggleSinglePages } from '../generate-single-page.ts' ;
77
88const contentRoot = 'docs/' ;
99
@@ -17,15 +17,11 @@ export default defineConfig({
1717 } ,
1818
1919 buildStart ( siteConfig ) {
20- // Generate single-page documentation for all products and APIs during dev if missing
21- generateAllSinglePages ( ) ;
22- // Generate toggle mode single-page documentation
20+ // Generate toggle mode single-page documentation during dev if missing
2321 generateAllToggleSinglePages ( ) ;
2422 } ,
2523
2624 buildEnd ( siteConfig ) {
27- // Generate single-page documentation for all products and APIs
28- generateAllSinglePages ( ) ;
2925 // Generate toggle mode single-page documentation
3026 generateAllToggleSinglePages ( ) ;
3127
@@ -402,42 +398,7 @@ function getNavBarItems(contentDir: string, appendNavBarWithContentDir: boolean
402398
403399}
404400
405- function getDynamicSinglePageNavItems ( sectionType : 'products' | 'api' ) : DefaultTheme . NavItemWithLink [ ] {
406- const navBarItems : DefaultTheme . NavItemWithLink [ ] = [ ] ;
407- const cwd = `${ process . cwd ( ) } /${ contentRoot } ` ;
408- const contentDir = `${ sectionType } /` ;
409-
410- const dirs = glob . sync ( `${ contentDir } /*/` , { cwd } ) . sort ( ) ;
411401
412- for ( const dirIndex in dirs ) {
413- const dir = dirs [ dirIndex ] ;
414- const productName = path . basename ( dir ) ;
415- const cleanName = productName . replace ( / ^ \d + - / , '' ) ;
416- const displayName = getPageName ( productName , false ) ;
417-
418- // Skip if no content exists
419- const productPath = path . join ( cwd , dir ) ;
420- if ( ! fs . existsSync ( productPath ) ) continue ;
421-
422- // Check if there are any markdown files in the product directory
423- const hasContent = hasMarkdownContent ( productPath ) ;
424- if ( ! hasContent ) continue ;
425-
426- const text = `${ displayName } (одна страница)` ;
427-
428- // New URL structure: /product-name/single-page or /api/product-name/single-page
429- let link : string ;
430- if ( sectionType === 'api' ) {
431- link = `/api/${ cleanName } /single-page` ;
432- } else {
433- link = `/${ cleanName } /single-page` ;
434- }
435-
436- navBarItems . push ( { text, link } ) ;
437- }
438-
439- return navBarItems ;
440- }
441402
442403function hasMarkdownContent ( directory : string ) : boolean {
443404 if ( ! fs . existsSync ( directory ) ) return false ;
@@ -463,38 +424,7 @@ function hasMarkdownContent(directory: string): boolean {
463424 return hasSubdirContent ;
464425}
465426
466- function generateAllSinglePages ( ) : void {
467- console . log ( 'Generating single-page documentation for all products and APIs...' ) ;
468-
469- const sections : ( 'products' | 'api' ) [ ] = [ 'products' , 'api' ] ;
470-
471- for ( const sectionType of sections ) {
472- const sectionPath = `docs/${ sectionType } ` ;
473-
474- if ( ! fs . existsSync ( sectionPath ) ) continue ;
475-
476- const products = fs . readdirSync ( sectionPath )
477- . filter ( item => {
478- const itemPath = path . join ( sectionPath , item ) ;
479- return fs . lstatSync ( itemPath ) . isDirectory ( ) || fs . lstatSync ( itemPath ) . isSymbolicLink ( ) ;
480- } ) ;
481-
482- for ( const productName of products ) {
483- const productPath = path . join ( sectionPath , productName ) ;
484-
485- // Check if product has markdown content
486- if ( hasMarkdownContent ( productPath ) ) {
487- try {
488- createSinglePageDocumentation ( sectionType , productName ) ;
489- } catch ( error ) {
490- console . warn ( `Failed to generate single-page for ${ sectionType } /${ productName } : ${ error . message } ` ) ;
491- }
492- }
493- }
494- }
495-
496- console . log ( 'Single-page documentation generation complete.' ) ;
497- }
427+
498428
499429function getProductDisplayName ( productName : string ) : string {
500430 // Remove number prefix and capitalize
@@ -514,42 +444,7 @@ function getProductDisplayName(productName: string): string {
514444 return displayNames [ cleanName ] || cleanName ;
515445}
516446
517- function getSinglePageSidebars ( ) : DefaultTheme . SidebarMulti {
518- const sidebars : DefaultTheme . SidebarMulti = { } ;
519- const cwd = `${ process . cwd ( ) } /${ contentRoot } ` ;
520-
521- // Generate sidebars for products
522- const productDirs = glob . sync ( `products/*/` , { cwd } ) . sort ( ) ;
523- for ( const dirIndex in productDirs ) {
524- const dir = productDirs [ dirIndex ] . replaceAll ( '\\' , '/' ) ;
525- const productName = path . basename ( dir ) ;
526- const cleanName = productName . replace ( / ^ \d + - / , '' ) ;
527-
528- // Check if product has content
529- const productPath = path . join ( cwd , dir ) ;
530- if ( ! hasMarkdownContent ( productPath ) ) continue ;
531-
532- const singlePageRoute = `/${ cleanName } /single-page` ;
533- sidebars [ singlePageRoute ] = generateSinglePageSidebar ( 'products' , productName , singlePageRoute ) ;
534- }
535-
536- // Generate sidebars for APIs
537- const apiDirs = glob . sync ( `api/*/` , { cwd } ) . sort ( ) ;
538- for ( const dirIndex in apiDirs ) {
539- const dir = apiDirs [ dirIndex ] . replaceAll ( '\\' , '/' ) ;
540- const productName = path . basename ( dir ) ;
541- const cleanName = productName . replace ( / ^ \d + - / , '' ) ;
542-
543- // Check if API has content
544- const apiPath = path . join ( cwd , dir ) ;
545- if ( ! hasMarkdownContent ( apiPath ) ) continue ;
546-
547- const singlePageRoute = `/api/${ cleanName } /single-page` ;
548- sidebars [ singlePageRoute ] = generateSinglePageSidebar ( 'api' , productName , singlePageRoute ) ;
549- }
550-
551- return sidebars ;
552- }
447+
553448
554449function getToggleModeNavItems ( ) : { products : DefaultTheme . NavItemWithLink [ ] , api : DefaultTheme . NavItemWithLink [ ] } {
555450 const cwd = `${ process . cwd ( ) } /${ contentRoot } ` ;
@@ -827,7 +722,6 @@ function generateAllSidebarConfigurations(): DefaultTheme.SidebarMulti {
827722
828723 // Get all individual sidebar configurations
829724 const toggleSidebars = getToggleModeSidebars ( ) ;
830- const singlePageSidebars = getSinglePageSidebars ( ) ;
831725 const productSidebars = getSidebars ( 'products/' , false , 'autumn' ) ;
832726 const apiSidebars = getSidebars ( 'api/' ) ;
833727
@@ -839,12 +733,7 @@ function generateAllSidebarConfigurations(): DefaultTheme.SidebarMulti {
839733 sidebarEntries . push ( [ route , sidebar ] ) ;
840734 }
841735
842- // 2. Regular single-page routes (very specific)
843- for ( const [ route , sidebar ] of Object . entries ( singlePageSidebars ) ) {
844- sidebarEntries . push ( [ route , sidebar ] ) ;
845- }
846-
847- // 3. Specific longer product and API routes first (autumn-collections before autumn)
736+ // 2. Specific longer product and API routes first (autumn-collections before autumn)
848737 const allRoutes = [
849738 ...Object . entries ( productSidebars ) ,
850739 ...Object . entries ( apiSidebars )
0 commit comments