File tree Expand file tree Collapse file tree 7 files changed +35
-19
lines changed Expand file tree Collapse file tree 7 files changed +35
-19
lines changed Original file line number Diff line number Diff line change 11import { minimatch } from 'minimatch' ;
22import { dev } from '$app/environment' ;
33import { index } from './content' ;
4+ import type { Topic } from '$lib/topics' ;
45
56interface GenerateLlmContentOptions {
67 ignore ?: string [ ] ;
@@ -16,11 +17,6 @@ interface MinimizeOptions {
1617 remove_prettier_ignore : boolean ;
1718}
1819
19- interface Topic {
20- slug : string ;
21- title : string ;
22- }
23-
2420const defaults : MinimizeOptions = {
2521 remove_legacy : false ,
2622 remove_note_blocks : false ,
@@ -63,12 +59,6 @@ export function generate_llm_content(options: GenerateLlmContentOptions): string
6359 return content ;
6460}
6561
66- export const topics : Topic [ ] = [
67- { slug : 'svelte' , title : 'Svelte' } ,
68- { slug : 'kit' , title : 'SvelteKit' } ,
69- { slug : 'cli' , title : 'the Svelte CLI' }
70- ] ;
71-
7262export function get_documentation_title ( topic : Topic ) : string {
7363 return `This is the developer documentation for ${ topic . title } .` ;
7464}
Original file line number Diff line number Diff line change 1+ export interface Topic {
2+ slug : string ;
3+ title : string ;
4+ }
5+
6+ export const topics = [
7+ { slug : 'svelte' , title : 'Svelte' } ,
8+ { slug : 'kit' , title : 'SvelteKit' } ,
9+ { slug : 'cli' , title : 'Svelte CLI' } ,
10+ { slug : 'mcp' , title : 'Svelte MCP' }
11+ ] as const satisfies Topic [ ] ;
12+
13+ const DEFAULT_TITLE = 'Svelte' ;
14+
15+ export function get_topic_title ( slug : string | undefined ) : string {
16+ if ( ! slug ) return DEFAULT_TITLE ;
17+ const topic = topics . find ( ( t ) => t . slug === slug ) ;
18+ return topic ?. title ?? DEFAULT_TITLE ;
19+ }
Original file line number Diff line number Diff line change 99 import { goto } from ' $app/navigation' ;
1010 import { escape_html } from ' $lib/utils/escape' ;
1111 import { page } from ' $app/state' ;
12+ import { get_topic_title } from ' $lib/topics' ;
1213
1314 let { data } = $props ();
1415
2223 return ` https://github.com/sveltejs/${name }/edit/main/documentation/${link } ` ;
2324 });
2425
26+ const topic_title = $derived (get_topic_title (page .params .topic ));
27+
2528 onMount (() => {
2629 // hash was lowercase in v4 docs and varying case in v5 docs
2730 const hash = location .hash .slice (1 );
5861 </script >
5962
6063<svelte:head >
61- <title >{data .document .metadata .title } • Docs • Svelte </title >
64+ <title >{data .document .metadata .title } • { topic_title } Docs </title >
6265
63- <meta name ="twitter:title" content =" {data .document .metadata .title } • Docs • Svelte " />
66+ <meta name ="twitter:title" content =" {data .document .metadata .title } • { topic_title } Docs " />
6467 <meta
6568 name =" twitter:description"
66- content =" {data .document .metadata .title } • Svelte documentation"
69+ content =" {data .document .metadata .title } • { topic_title } documentation"
6770 />
6871 <meta name =" twitter:card" content =" summary_large_image" />
69- <meta name ="description" content =" {data .document .metadata .title } • Svelte documentation" />
72+ <meta name ="description" content =" {data .document .metadata .title } • { topic_title } documentation" />
7073 <meta
7174 name =" twitter:image"
7275 content ="https://svelte.dev/docs/ {page .params .topic }/ {page .params .path }/card.png"
Original file line number Diff line number Diff line change 11import { error } from '@sveltejs/kit' ;
22import { docs } from '$lib/server/content.js' ;
3- import { generate_llm_content , get_documentation_title , topics } from '$lib/server/llms' ;
3+ import { generate_llm_content , get_documentation_title } from '$lib/server/llms' ;
4+ import { topics } from '$lib/topics' ;
45
56export const prerender = true ;
67
Original file line number Diff line number Diff line change 1- import { generate_llm_content , topics } from '$lib/server/llms' ;
1+ import { generate_llm_content } from '$lib/server/llms' ;
2+ import { topics } from '$lib/topics' ;
23
34export const prerender = true ;
45
Original file line number Diff line number Diff line change 1- import { generate_llm_content , topics } from '$lib/server/llms' ;
1+ import { generate_llm_content } from '$lib/server/llms' ;
2+ import { topics } from '$lib/topics' ;
23
34export function GET ( ) {
45 const main_content = generate_llm_content ( {
Original file line number Diff line number Diff line change 1- import { get_documentation_title , topics } from '$lib/server/llms' ;
1+ import { get_documentation_title } from '$lib/server/llms' ;
2+ import { topics } from '$lib/topics' ;
23import template from './template.md?raw' ;
34
45const DOMAIN = `https://svelte.dev` ;
You can’t perform that action at this time.
0 commit comments