Skip to content

Commit e5faa91

Browse files
feat: enhance synced repo exclusion logic in VitePress config
1 parent 2c32a81 commit e5faa91

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

.vitepress/config.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { existsSync, readdirSync } from 'node:fs'
2+
import { join } from 'node:path'
3+
import { fileURLToPath } from 'node:url'
14
import { defineConfig } from 'vitepress'
25
import { generatedNav, generatedSidebar, generatedEditLinkPattern } from './config.generated'
36

@@ -6,11 +9,25 @@ const SITE_TITLE = "Home"
69
const SITE_DESCRIPTION = 'Centralized developer documentation hub for all @KevinDeBenedetti open source projects.'
710
const OG_IMAGE = `${SITE_URL}/og-image.png`
811

12+
// Root of the repository (parent of .vitepress/)
13+
const ROOT = fileURLToPath(new URL('..', import.meta.url))
14+
const SYNCED_DIR = join(ROOT, 'synced')
15+
16+
// Exclude any root-level folder that matches a synced repo name.
17+
// sync-docs.ts populates synced/ before vitepress build runs; without this guard
18+
// a root-level folder committed by an old cd-docs.yml run would produce duplicate
19+
// URLs alongside synced/:slug/* rewrites and crash MiniSearch (duplicate IDs).
20+
const syncedRepoExcludes = existsSync(SYNCED_DIR)
21+
? readdirSync(SYNCED_DIR, { withFileTypes: true })
22+
.filter(d => d.isDirectory())
23+
.map(d => `${d.name}/**`)
24+
: []
25+
926
// https://vitepress.dev/reference/site-config
1027
// Static base config — nav/sidebar/editLink are in config.generated.ts (auto-generated)
1128
export default defineConfig({
1229
srcDir: '.',
13-
srcExclude: ['README.md', 'TODO.md'],
30+
srcExclude: ['README.md', 'TODO.md', ...syncedRepoExcludes],
1431
rewrites: {
1532
'docs/index.md': 'index.md',
1633
'docs/:slug/:rest*': ':slug/:rest*',

0 commit comments

Comments
 (0)