@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 +1 -1
- package/package.json +1 -1
- package/src/mcp/server.js +11 -5
package/bin/docsector.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docsector/docsector-reader",
|
|
3
|
-
"version": "2.0.
|
|
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 = [
|
|
155
|
+
const attempts = [path]
|
|
155
156
|
if (!path.endsWith('/overview') && !path.endsWith('/showcase') && !path.endsWith('/vs')) {
|
|
156
|
-
attempts.push(
|
|
157
|
+
attempts.push(`${path}/overview`)
|
|
157
158
|
}
|
|
158
159
|
|
|
159
|
-
for (const
|
|
160
|
-
|
|
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: [{
|