Skip to content

Commit ddba550

Browse files
docs: point readers (and their LLMs) at the markdown renditions (#2427)
1 parent 43c13c5 commit ddba550

4 files changed

Lines changed: 48 additions & 1 deletion

File tree

docs/.vitepress/config.mts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ export default defineConfig({
5353
buildEnd(siteConfig) {
5454
generateLlmsArtifacts(docsDir, siteConfig.outDir, siteUrl);
5555
},
56+
transformPageData(pageData) {
57+
// Every guide page has a markdown rendition next to its HTML (llms.ts);
58+
// advertise it to tools via a rel=alternate link. The API reference has none.
59+
if (!pageData.relativePath.startsWith('api/')) {
60+
pageData.frontmatter.head ??= [];
61+
pageData.frontmatter.head.push([
62+
'link',
63+
{ rel: 'alternate', type: 'text/markdown', href: `${siteUrl}/${pageData.relativePath}` }
64+
]);
65+
}
66+
},
5667
themeConfig: {
5768
nav: [
5869
{ text: 'Get started', link: '/get-started/first-server', activeMatch: '^/get-started/' },
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script setup lang="ts">
2+
import { useData, withBase } from 'vitepress';
3+
import { computed } from 'vue';
4+
5+
// Every guide page has a markdown rendition generated next to its HTML (see
6+
// ../llms.ts); the generated API reference does not.
7+
const { page } = useData();
8+
const mdPath = computed(() => (page.value.relativePath.startsWith('api/') ? undefined : withBase(`/${page.value.relativePath}`)));
9+
</script>
10+
11+
<template>
12+
<div v-if="mdPath" class="markdown-source">
13+
Are you an LLM (or feeding one)? This page as
14+
<a :href="mdPath" target="_self">markdown</a> · <a :href="withBase('/llms.txt')" target="_self">llms.txt</a> ·
15+
<a :href="withBase('/llms-full.txt')" target="_self">llms-full.txt</a>
16+
</div>
17+
</template>

docs/.vitepress/theme/custom.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,20 @@
171171
text-decoration: underline;
172172
margin-left: 4px;
173173
}
174+
175+
/* --------------------------------------------------- markdown-source footer */
176+
177+
.markdown-source {
178+
margin-bottom: 16px;
179+
padding-top: 16px;
180+
border-top: 1px solid var(--vp-c-divider);
181+
color: var(--vp-c-text-3);
182+
font-size: 12px;
183+
line-height: 1.5;
184+
}
185+
186+
.markdown-source a {
187+
color: var(--vp-c-text-2);
188+
text-decoration: underline;
189+
font-weight: 400;
190+
}

docs/.vitepress/theme/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import DefaultTheme from 'vitepress/theme';
33
import { h } from 'vue';
44

55
import Banner from './Banner.vue';
6+
import MarkdownSource from './MarkdownSource.vue';
67
import './custom.css';
78

89
export default {
910
extends: DefaultTheme,
1011
Layout() {
1112
return h(DefaultTheme.Layout, null, {
12-
'layout-top': () => h(Banner)
13+
'layout-top': () => h(Banner),
14+
'doc-footer-before': () => h(MarkdownSource)
1315
});
1416
}
1517
} satisfies Theme;

0 commit comments

Comments
 (0)