@docsector/docsector-reader 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/docsector.js CHANGED
@@ -23,7 +23,7 @@ const packageRoot = resolve(__dirname, '..')
23
23
  const args = process.argv.slice(2)
24
24
  const command = args[0]
25
25
 
26
- const VERSION = '2.0.0'
26
+ const VERSION = '2.0.1'
27
27
 
28
28
  const HELP = `
29
29
  Docsector Reader v${VERSION}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docsector/docsector-reader",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "A documentation rendering engine built with Vue 3, Quasar v2 and Vite. Transform Markdown into beautiful, navigable documentation sites.",
5
5
  "productName": "Docsector Reader",
6
6
  "author": "Rodrigo de Araujo Vieira",
@@ -347,6 +347,32 @@ async function loadBooksRegistry (projectRoot) {
347
347
  }
348
348
  }
349
349
 
350
+ /**
351
+ * Return page entries while preserving the book that contributed each route.
352
+ *
353
+ * Why: `allPages` is a legacy flattened registry and cannot represent two
354
+ * books that reuse the same route key, such as `/getting-started` in both
355
+ * `guide.index.js` and `manual.index.js`. Build artifacts that need concrete
356
+ * URLs must iterate per book instead.
357
+ */
358
+ function getBookPageEntries (books = {}) {
359
+ const pageEntries = []
360
+
361
+ for (const [bookId, book] of Object.entries(books || {})) {
362
+ const fallbackBook = book?.config?.id || bookId || 'manual'
363
+
364
+ for (const [pagePath, page] of Object.entries(book?.routes || {})) {
365
+ pageEntries.push({
366
+ book: resolvePageBook(page?.config, fallbackBook),
367
+ pagePath,
368
+ page
369
+ })
370
+ }
371
+ }
372
+
373
+ return pageEntries
374
+ }
375
+
350
376
  /**
351
377
  * Check if a file path is a book registry definition file.
352
378
  */
@@ -463,7 +489,8 @@ function createPrerenderMetaPlugin (projectRoot) {
463
489
  // Dynamic import books registry and docsector config
464
490
  const configUrl = pathToFileURL(resolve(projectRoot, 'docsector.config.js')).href
465
491
 
466
- const { allPages: pages } = await loadBooksRegistry(projectRoot)
492
+ const { books } = await loadBooksRegistry(projectRoot)
493
+ const pageEntries = getBookPageEntries(books)
467
494
  const { default: config } = await import(configUrl)
468
495
 
469
496
  const brandingName = config.branding?.name || ''
@@ -481,10 +508,9 @@ function createPrerenderMetaPlugin (projectRoot) {
481
508
 
482
509
  let count = 0
483
510
 
484
- for (const [pagePath, page] of Object.entries(pages)) {
511
+ for (const { book, pagePath, page } of pageEntries) {
485
512
  if (page.config === null) continue
486
513
 
487
- const book = resolvePageBook(page.config, 'manual')
488
514
  const titleData = page.data?.[defaultLang] || page.data?.['*'] || page.data?.['en-US'] || Object.values(page.data || {})[0]
489
515
  const title = titleData?.title || ''
490
516
  const fullTitle = title
@@ -1075,17 +1101,16 @@ function createMarkdownBuildPlugin (projectRoot) {
1075
1101
  const configUrl = pathToFileURL(resolve(projectRoot, 'docsector.config.js')).href
1076
1102
 
1077
1103
  const { default: config } = await import(configUrl)
1078
- const { allPages: pages } = await loadBooksRegistry(projectRoot)
1104
+ const { books } = await loadBooksRegistry(projectRoot)
1105
+ const pageEntries = getBookPageEntries(books)
1079
1106
 
1080
1107
  const defaultLang = config.defaultLanguage || config.languages?.[0]?.value || 'en-US'
1081
1108
  let count = 0
1082
1109
 
1083
- for (const [pagePath, page] of Object.entries(pages)) {
1110
+ for (const { book, pagePath, page } of pageEntries) {
1084
1111
  if (page.config === null) continue
1085
1112
  if (page.config.status === 'empty') continue
1086
1113
 
1087
- const book = resolvePageBook(page.config, 'manual')
1088
-
1089
1114
  const subpages = ['overview']
1090
1115
  if (page.config.subpages?.showcase) subpages.push('showcase')
1091
1116
  if (page.config.subpages?.vs) subpages.push('vs')
@@ -1129,12 +1154,10 @@ function createMarkdownBuildPlugin (projectRoot) {
1129
1154
  const today = new Date().toISOString().split('T')[0]
1130
1155
  let urls = ''
1131
1156
 
1132
- for (const [pagePath, page] of Object.entries(pages)) {
1157
+ for (const { book, pagePath, page } of pageEntries) {
1133
1158
  if (page.config === null) continue
1134
1159
  if (page.config.status === 'empty') continue
1135
1160
 
1136
- const book = resolvePageBook(page.config, 'manual')
1137
-
1138
1161
  const subpages = ['overview']
1139
1162
  if (page.config.subpages?.showcase) subpages.push('showcase')
1140
1163
  if (page.config.subpages?.vs) subpages.push('vs')
@@ -1162,11 +1185,10 @@ function createMarkdownBuildPlugin (projectRoot) {
1162
1185
 
1163
1186
  const llmsSections = {}
1164
1187
 
1165
- for (const [pagePath, page] of Object.entries(pages)) {
1188
+ for (const { book, pagePath, page } of pageEntries) {
1166
1189
  if (page.config === null) continue
1167
1190
  if (page.config.status === 'empty') continue
1168
1191
 
1169
- const book = resolvePageBook(page.config, 'manual')
1170
1192
  const title = page.data?.['*']?.title
1171
1193
  || page.data?.[defaultLang]?.title
1172
1194
  || page.data?.['en-US']?.title
@@ -1783,11 +1805,10 @@ export async function onRequest (context) {
1783
1805
 
1784
1806
  // Collect page index for MCP
1785
1807
  const mcpPages = []
1786
- for (const [pagePath, page] of Object.entries(pages)) {
1808
+ for (const { book, pagePath, page } of pageEntries) {
1787
1809
  if (page.config === null) continue
1788
1810
  if (page.config.status === 'empty') continue
1789
1811
 
1790
- const book = resolvePageBook(page.config, 'manual')
1791
1812
  const defaultTitle = page.data?.['*']?.title
1792
1813
  || page.data?.[defaultLang]?.title
1793
1814
  || page.data?.['en-US']?.title