@docsector/docsector-reader 0.8.1 → 0.8.4

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 = '0.8.1'
26
+ const VERSION = '0.8.4'
27
27
 
28
28
  const HELP = `
29
29
  Docsector Reader v${VERSION}
@@ -686,6 +686,96 @@ npm-debug.log*
686
686
  .thumbs.db
687
687
  `
688
688
 
689
+ const TEMPLATE_ROBOTS_TXT = `\
690
+ User-agent: *
691
+ Allow: /
692
+
693
+ # Explicitly allow AI crawlers
694
+ # OpenAI
695
+ User-agent: GPTBot
696
+ Allow: /
697
+
698
+ User-agent: ChatGPT-User
699
+ Allow: /
700
+
701
+ User-agent: OAI-SearchBot
702
+ Allow: /
703
+
704
+ # Anthropic
705
+ User-agent: ClaudeBot
706
+ Allow: /
707
+
708
+ User-agent: Claude-User
709
+ Allow: /
710
+
711
+ User-agent: Claude-SearchBot
712
+ Allow: /
713
+
714
+ User-agent: anthropic-ai
715
+ Allow: /
716
+
717
+ # Google
718
+ User-agent: Google-Extended
719
+ Allow: /
720
+
721
+ User-agent: Gemini-Deep-Research
722
+ Allow: /
723
+
724
+ # Perplexity
725
+ User-agent: PerplexityBot
726
+ Allow: /
727
+
728
+ User-agent: Perplexity-User
729
+ Allow: /
730
+
731
+ # ByteDance
732
+ User-agent: Bytespider
733
+ Allow: /
734
+
735
+ # Common Crawl
736
+ User-agent: CCBot
737
+ Allow: /
738
+
739
+ # Meta
740
+ User-agent: Meta-ExternalAgent
741
+ Allow: /
742
+
743
+ User-agent: FacebookBot
744
+ Allow: /
745
+
746
+ # Amazon
747
+ User-agent: Amazonbot
748
+ Allow: /
749
+
750
+ # Apple
751
+ User-agent: Applebot-Extended
752
+ Allow: /
753
+
754
+ # Cohere
755
+ User-agent: cohere-ai
756
+ Allow: /
757
+
758
+ # DuckDuckGo
759
+ User-agent: DuckAssistBot
760
+ Allow: /
761
+
762
+ # xAI
763
+ User-agent: GrokBot
764
+ Allow: /
765
+
766
+ # Allen AI
767
+ User-agent: AI2Bot
768
+ Allow: /
769
+
770
+ # You.com
771
+ User-agent: YouBot
772
+ Allow: /
773
+
774
+ # Huawei
775
+ User-agent: PetalBot
776
+ Allow: /
777
+ `
778
+
689
779
  const TEMPLATE_GETTING_STARTED_MD = `\
690
780
  ## Installation
691
781
 
@@ -840,6 +930,7 @@ function initProject (name) {
840
930
  ['index.html', TEMPLATE_INDEX_HTML],
841
931
  ['postcss.config.cjs', TEMPLATE_POSTCSS],
842
932
  ['.gitignore', TEMPLATE_GITIGNORE],
933
+ ['public/robots.txt', TEMPLATE_ROBOTS_TXT],
843
934
  ['src/css/app.sass', TEMPLATE_CSS_STUB],
844
935
  ['src/i18n/index.js', TEMPLATE_I18N_INDEX],
845
936
  ['src/i18n/languages/en-US.hjson', TEMPLATE_I18N_HJSON],
@@ -869,6 +960,7 @@ function initProject (name) {
869
960
  console.log(' ├── postcss.config.cjs')
870
961
  console.log(' ├── .gitignore')
871
962
  console.log(' ├── public/')
963
+ console.log(' │ ├── robots.txt')
872
964
  console.log(' │ └── images/')
873
965
  console.log(' │ └── logo.png')
874
966
  console.log(' └── src/')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docsector/docsector-reader",
3
- "version": "0.8.1",
3
+ "version": "0.8.4",
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",
@@ -360,7 +360,7 @@ function createMarkdownEndpointPlugin (projectRoot) {
360
360
  if (!file) return next()
361
361
 
362
362
  const content = readFileSync(file, 'utf-8')
363
- res.setHeader('Content-Type', 'text/plain; charset=utf-8')
363
+ res.setHeader('Content-Type', 'text/markdown; charset=utf-8')
364
364
  res.end(content)
365
365
  return
366
366
  }
@@ -374,7 +374,7 @@ function createMarkdownEndpointPlugin (projectRoot) {
374
374
  const file = resolveMarkdownFile(mdPath, lang)
375
375
  if (file) {
376
376
  const content = readFileSync(file, 'utf-8')
377
- res.setHeader('Content-Type', 'text/plain; charset=utf-8')
377
+ res.setHeader('Content-Type', 'text/markdown; charset=utf-8')
378
378
  res.end(content)
379
379
  return
380
380
  }
@@ -438,6 +438,49 @@ function createMarkdownBuildPlugin (projectRoot) {
438
438
  }
439
439
 
440
440
  console.log(`\x1b[36m[docsector]\x1b[0m Generated ${count} static .md files`)
441
+
442
+ // Generate sitemap.xml if siteUrl is configured
443
+ const siteUrl = (config.siteUrl || '').replace(/\/+$/, '')
444
+ if (siteUrl) {
445
+ const today = new Date().toISOString().split('T')[0]
446
+ let urls = ''
447
+
448
+ for (const [pagePath, page] of Object.entries(pages)) {
449
+ if (page.config === null) continue
450
+ if (page.config.status === 'empty') continue
451
+
452
+ const type = page.config.type ?? 'manual'
453
+
454
+ const subpages = ['overview']
455
+ if (page.config.subpages?.showcase) subpages.push('showcase')
456
+ if (page.config.subpages?.vs) subpages.push('vs')
457
+
458
+ for (const subpage of subpages) {
459
+ const srcFile = resolve(pagesDir, `${type}${pagePath}.${subpage}.${defaultLang}.md`)
460
+ if (!existsSync(srcFile)) continue
461
+
462
+ const routePath = `/${type}${pagePath}/${subpage}`
463
+ urls += ` <url>\n <loc>${siteUrl}${routePath}</loc>\n <lastmod>${today}</lastmod>\n </url>\n`
464
+ }
465
+ }
466
+
467
+ const sitemap = `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${urls}</urlset>\n`
468
+ writeFileSync(resolve(distDir, 'sitemap.xml'), sitemap)
469
+ console.log(`\x1b[36m[docsector]\x1b[0m Generated sitemap.xml`)
470
+ }
471
+
472
+ // Generate _headers file for Cloudflare Pages (append if exists)
473
+ const headersPath = resolve(distDir, '_headers')
474
+ const headersRule = '/*.md\n Content-Type: text/markdown; charset=utf-8\n'
475
+ if (existsSync(headersPath)) {
476
+ const existing = readFileSync(headersPath, 'utf-8')
477
+ if (!existing.includes('*.md')) {
478
+ writeFileSync(headersPath, existing.trimEnd() + '\n\n' + headersRule)
479
+ }
480
+ } else {
481
+ writeFileSync(headersPath, headersRule)
482
+ }
483
+ console.log(`\x1b[36m[docsector]\x1b[0m Added _headers rule for .md files`)
441
484
  }
442
485
  }
443
486
  }