Skip to content

Commit 16c42ce

Browse files
committed
feat(llm-docs): add alternate link tags for llms.txt and .md routes
Add <link rel="alternate"> tags to HTML head for LLM-friendly document discovery on homepage, org pages, and package pages.
1 parent 448eac0 commit 16c42ce

3 files changed

Lines changed: 37 additions & 2 deletions

File tree

app/pages/index.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ async function search() {
1010
1111
const { env } = useAppConfig().buildInfo
1212
13+
useHead({
14+
link: [{ key: 'llms-txt', rel: 'alternate', href: '/llms.txt', title: 'LLMs.txt' }],
15+
})
16+
1317
useSeoMeta({
1418
title: () => $t('seo.home.title'),
1519
ogTitle: () => $t('seo.home.title'),

app/pages/org/[org].vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,15 @@ const activeTab = shallowRef<'members' | 'teams'>('members')
129129
const canonicalUrl = computed(() => `https://npmx.dev/@${orgName.value}`)
130130
131131
useHead({
132-
link: [{ rel: 'canonical', href: canonicalUrl }],
132+
link: [
133+
{ rel: 'canonical', href: canonicalUrl },
134+
{
135+
key: 'llms-txt',
136+
rel: 'alternate',
137+
href: () => `/package/@${orgName.value}/llms.txt`,
138+
title: 'LLMs.txt',
139+
},
140+
],
133141
})
134142
135143
useSeoMeta({

app/pages/package/[[org]]/[name].vue

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,30 @@ const compactNumberFormatter = useCompactNumberFormatter()
669669
const bytesFormatter = useBytesFormatter()
670670
671671
useHead({
672-
link: [{ rel: 'canonical', href: canonicalUrl }],
672+
link: computed(() => {
673+
const base = `/package/${packageName.value}`
674+
const versionSegment = requestedVersion.value ? `/v/${requestedVersion.value}` : ''
675+
const links: Array<{ key?: string; rel: string; href: string; title?: string }> = [
676+
{ rel: 'canonical', href: canonicalUrl.value },
677+
{
678+
key: 'llms-txt',
679+
rel: 'alternate',
680+
href: `${base}${versionSegment}/llms.txt`,
681+
title: 'LLMs.txt',
682+
},
683+
{
684+
key: 'llms-full-txt',
685+
rel: 'alternate',
686+
href: `${base}${versionSegment}/llms-full.txt`,
687+
title: 'LLMs-full.txt',
688+
},
689+
]
690+
// .md routes only support latest version (no /v/ variant)
691+
if (!requestedVersion.value) {
692+
links.push({ key: 'pkg-md', rel: 'alternate', href: `${base}.md`, title: 'Markdown version' })
693+
}
694+
return links
695+
}),
673696
})
674697
675698
useSeoMeta({

0 commit comments

Comments
 (0)