@docsector/docsector-reader 2.0.1 → 2.0.2

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.1'
26
+ const VERSION = '2.0.2'
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.1",
3
+ "version": "2.0.2",
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",
package/src/mcp/server.js CHANGED
@@ -149,21 +149,27 @@ async function handleGetPage (args, env) {
149
149
  }
150
150
 
151
151
  const siteBase = SITE_URL || 'http://localhost'
152
+ const pages = await getPages(env)
152
153
 
153
154
  // Try the path as-is, then with /overview appended
154
- const attempts = [`/${path}.md`]
155
+ const attempts = [path]
155
156
  if (!path.endsWith('/overview') && !path.endsWith('/showcase') && !path.endsWith('/vs')) {
156
- attempts.push(`/${path}/overview.md`)
157
+ attempts.push(`${path}/overview`)
157
158
  }
158
159
 
159
- for (const mdPath of attempts) {
160
- const url = new URL(mdPath, siteBase)
160
+ for (const pagePath of attempts) {
161
+ if (!pages.some(page => page.path === pagePath)) continue
162
+
163
+ const url = new URL(`/${pagePath}.md`, siteBase)
161
164
  const res = await env.ASSETS.fetch(url.toString())
162
165
 
163
166
  if (res.ok) {
164
167
  const text = await res.text()
168
+ const contentType = res.headers.get('content-type') || ''
169
+ const looksLikeHtml = /^\s*<!doctype\s+html/i.test(text) || /^\s*<html[\s>]/i.test(text)
170
+ if (contentType.includes('text/html') || looksLikeHtml) continue
171
+
165
172
  const siteUrl = siteBase.replace(/\/+$/, '')
166
- const pagePath = mdPath.replace(/^\//, '').replace(/\.md$/, '')
167
173
 
168
174
  return {
169
175
  content: [{