diff --git a/apps/svelte.dev/src/lib/server/llms.ts b/apps/svelte.dev/src/lib/server/llms.ts index 549d39592a..02e7b66d1f 100644 --- a/apps/svelte.dev/src/lib/server/llms.ts +++ b/apps/svelte.dev/src/lib/server/llms.ts @@ -1,6 +1,7 @@ import { minimatch } from 'minimatch'; import { dev } from '$app/environment'; import { index } from './content'; +import type { Topic } from '$lib/topics'; interface GenerateLlmContentOptions { ignore?: string[]; @@ -16,11 +17,6 @@ interface MinimizeOptions { remove_prettier_ignore: boolean; } -interface Topic { - slug: string; - title: string; -} - const defaults: MinimizeOptions = { remove_legacy: false, remove_note_blocks: false, @@ -63,12 +59,6 @@ export function generate_llm_content(options: GenerateLlmContentOptions): string return content; } -export const topics: Topic[] = [ - { slug: 'svelte', title: 'Svelte' }, - { slug: 'kit', title: 'SvelteKit' }, - { slug: 'cli', title: 'the Svelte CLI' } -]; - export function get_documentation_title(topic: Topic): string { return `This is the developer documentation for ${topic.title}.`; } diff --git a/apps/svelte.dev/src/lib/topics.ts b/apps/svelte.dev/src/lib/topics.ts new file mode 100644 index 0000000000..2b08897efb --- /dev/null +++ b/apps/svelte.dev/src/lib/topics.ts @@ -0,0 +1,19 @@ +export interface Topic { + slug: string; + title: string; +} + +export const topics = [ + { slug: 'svelte', title: 'Svelte' }, + { slug: 'kit', title: 'SvelteKit' }, + { slug: 'cli', title: 'Svelte CLI' }, + { slug: 'mcp', title: 'Svelte MCP' } +] as const satisfies Topic[]; + +const DEFAULT_TITLE = 'Svelte'; + +export function get_topic_title(slug: string | undefined): string { + if (!slug) return DEFAULT_TITLE; + const topic = topics.find((t) => t.slug === slug); + return topic?.title ?? DEFAULT_TITLE; +} diff --git a/apps/svelte.dev/src/routes/docs/[topic]/[...path]/+page.svelte b/apps/svelte.dev/src/routes/docs/[topic]/[...path]/+page.svelte index 717ac752ec..2af29fa6eb 100644 --- a/apps/svelte.dev/src/routes/docs/[topic]/[...path]/+page.svelte +++ b/apps/svelte.dev/src/routes/docs/[topic]/[...path]/+page.svelte @@ -9,6 +9,7 @@ import { goto } from '$app/navigation'; import { escape_html } from '$lib/utils/escape'; import { page } from '$app/state'; + import { get_topic_title } from '$lib/topics'; let { data } = $props(); @@ -22,6 +23,8 @@ return `https://github.com/sveltejs/${name}/edit/main/documentation/${link}`; }); + const topic_title = $derived(get_topic_title(page.params.topic)); + onMount(() => { // hash was lowercase in v4 docs and varying case in v5 docs const hash = location.hash.slice(1); @@ -58,15 +61,15 @@ - {data.document.metadata.title} • Docs • Svelte + {data.document.metadata.title} • {topic_title} Docs - + - +