Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions apps/svelte.dev/src/lib/server/llms.ts
Original file line number Diff line number Diff line change
@@ -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[];
Expand All @@ -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,
Expand Down Expand Up @@ -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}.`;
}
Expand Down
19 changes: 19 additions & 0 deletions apps/svelte.dev/src/lib/topics.ts
Original file line number Diff line number Diff line change
@@ -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;
}
11 changes: 7 additions & 4 deletions apps/svelte.dev/src/routes/docs/[topic]/[...path]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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);
Expand Down Expand Up @@ -58,15 +61,15 @@
</script>

<svelte:head>
<title>{data.document.metadata.title} • Docs • Svelte</title>
<title>{data.document.metadata.title} • {topic_title} Docs</title>

<meta name="twitter:title" content="{data.document.metadata.title} • Docs • Svelte" />
<meta name="twitter:title" content="{data.document.metadata.title} • {topic_title} Docs" />
<meta
name="twitter:description"
content="{data.document.metadata.title} • Svelte documentation"
content="{data.document.metadata.title} • {topic_title} documentation"
/>
<meta name="twitter:card" content="summary_large_image" />
<meta name="description" content="{data.document.metadata.title} • Svelte documentation" />
<meta name="description" content="{data.document.metadata.title} • {topic_title} documentation" />
<meta
name="twitter:image"
content="https://svelte.dev/docs/{page.params.topic}/{page.params.path}/card.png"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { error } from '@sveltejs/kit';
import { docs } from '$lib/server/content.js';
import { generate_llm_content, get_documentation_title, topics } from '$lib/server/llms';
import { generate_llm_content, get_documentation_title } from '$lib/server/llms';
import { topics } from '$lib/topics';

export const prerender = true;

Expand Down
3 changes: 2 additions & 1 deletion apps/svelte.dev/src/routes/llms-full.txt/+server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { generate_llm_content, topics } from '$lib/server/llms';
import { generate_llm_content } from '$lib/server/llms';
import { topics } from '$lib/topics';

export const prerender = true;

Expand Down
3 changes: 2 additions & 1 deletion apps/svelte.dev/src/routes/llms-medium.txt/+server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { generate_llm_content, topics } from '$lib/server/llms';
import { generate_llm_content } from '$lib/server/llms';
import { topics } from '$lib/topics';

export function GET() {
const main_content = generate_llm_content({
Expand Down
3 changes: 2 additions & 1 deletion apps/svelte.dev/src/routes/llms.txt/+server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { get_documentation_title, topics } from '$lib/server/llms';
import { get_documentation_title } from '$lib/server/llms';
import { topics } from '$lib/topics';
import template from './template.md?raw';

const DOMAIN = `https://svelte.dev`;
Expand Down