Skip to content

Commit dd11300

Browse files
committed
fix: view as markdown
1 parent 8c8f520 commit dd11300

4 files changed

Lines changed: 19 additions & 8 deletions

File tree

.vitepress/config.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ export default defineConfig({
6060
title: 'NativeScript',
6161
description:
6262
'NativeScript empowers you to access native platform APIs from JavaScript directly. Develop iOS, Android and visionOS apps with TypeScript, Angular, Vue, React, Svelte or Solid.',
63+
// also emit /index.md for the home page (default skips it)
64+
excludeIndexPage: false,
6365
}),
6466
],
6567
},

.vitepress/theme/CopyPageButton.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ const open = ref(false)
1111
const copied = ref(false)
1212
const root = ref<HTMLElement | null>(null)
1313
14-
const mdPath = computed(() => '/' + page.value.relativePath)
14+
// mirrors the vitepress-plugin-llms output layout: "dir/index.md" twins are
15+
// written to "/dir.md"; the root "index.md" keeps its name
16+
const mdPath = computed(() => {
17+
const rel = '/' + page.value.relativePath
18+
if (rel !== '/index.md' && rel.endsWith('/index.md')) {
19+
return rel.slice(0, -'/index.md'.length) + '.md'
20+
}
21+
return rel
22+
})
1523
const mdUrl = computed(() => SITE_ORIGIN + mdPath.value)
1624
1725
const chatGptUrl = computed(

functions/mcp.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,13 @@ async function getPage(context: any, path: string) {
171171
clean = clean.replace(/\/$/, '') || '/index'
172172
clean += '.md'
173173
}
174-
// root index special case
175-
if (clean === '/.md') clean = '/index.md'
176-
177-
let res = await fetchAsset(context, clean)
178-
if (!res.ok && clean.endsWith('.md')) {
179-
// pages like /api/namespaces/Utils/ map to index.md in their directory
180-
res = await fetchAsset(context, clean.replace(/\.md$/, '/index.md'))
174+
// markdown twins follow the vitepress-plugin-llms layout:
175+
// "dir/index.md" is written to "/dir.md"; the root "index.md" keeps its name
176+
if (clean !== '/index.md' && clean.endsWith('/index.md')) {
177+
clean = clean.slice(0, -'/index.md'.length) + '.md'
181178
}
179+
180+
const res = await fetchAsset(context, clean)
182181
if (!res.ok) {
183182
return textContent(
184183
`Page not found: ${clean}. Use search_docs or get_sitemap to find valid paths.`,

tools/smoke/smoke.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ report(
9595
'/api/classes/Button.md is raw markdown'
9696
)
9797
await checkPage('/guide/ai.md', ['MCP'])
98+
await checkPage('/index.md', ['NativeScript'])
99+
await checkPage('/guide/publishing.md', ['Publishing'])
98100

99101
// ---- llms.txt + API index ----
100102
await checkPage('/llms.txt', ['# NativeScript', 'Table of Contents'])

0 commit comments

Comments
 (0)