File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { existsSync } from 'fs' ;
2+ import { join } from 'path' ;
3+
4+ /**
5+ * Detects the base directory containing the docs content (python-sdk/, infrahubctl/, etc.).
6+ *
7+ * The sidebar files live in different locations depending on which repo they are in:
8+ * - infrahub-sdk-python: docs/sidebars/ → content is at docs/docs/
9+ * - infrahub-docs: docs/ → content is at docs/docs-python-sdk/
10+ *
11+ * We detect the active layout by checking whether the SDK-repo content path exists.
12+ */
13+ export function getDocsBaseDir ( ) : string {
14+ const sdkRepoDocsDir = join ( __dirname , '..' , 'docs' ) ;
15+ if ( existsSync ( join ( sdkRepoDocsDir , 'python-sdk' ) ) ) {
16+ return sdkRepoDocsDir ;
17+ }
18+ return join ( __dirname , 'docs-python-sdk' ) ;
19+ }
20+
121export function getCommandItems ( files : string [ ] , indexFile : string = 'infrahubctl.mdx' ) : string [ ] {
222 return files
323 . filter ( file => file . endsWith ( '.mdx' ) && file !== indexFile )
Original file line number Diff line number Diff line change 11import type { SidebarsConfig } from '@docusaurus/plugin-content-docs' ;
22import { readdirSync } from 'fs' ;
33import { join } from 'path' ;
4- import { getCommandItems } from './sidebar-utils' ;
4+ import { getCommandItems , getDocsBaseDir } from './sidebar-utils' ;
55
6- const docsDir = join ( __dirname , '..' , 'docs' , 'infrahubctl' ) ;
6+ const docsDir = join ( getDocsBaseDir ( ) , 'infrahubctl' ) ;
77const commandItems = getCommandItems ( readdirSync ( docsDir ) ) ;
88
99const sidebars : SidebarsConfig = {
Original file line number Diff line number Diff line change 11import type { SidebarsConfig } from '@docusaurus/plugin-content-docs' ;
22import { readdirSync } from 'fs' ;
33import { join } from 'path' ;
4- import { getItemsWithOrder } from './sidebar-utils' ;
4+ import { getDocsBaseDir , getItemsWithOrder } from './sidebar-utils' ;
55
6- const pythonSdkDocsDir = join ( __dirname , '..' , 'docs' , 'python-sdk' ) ;
6+ const pythonSdkDocsDir = join ( getDocsBaseDir ( ) , 'python-sdk' ) ;
77
88const guidesItems = getItemsWithOrder (
99 readdirSync ( join ( pythonSdkDocsDir , 'guides' ) ) ,
You can’t perform that action at this time.
0 commit comments