File tree Expand file tree Collapse file tree 2 files changed +9
-13
lines changed
routes/docs/[...path]/llms.txt Expand file tree Collapse file tree 2 files changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -130,34 +130,31 @@ function create_docs() {
130130
131131export const docs = create_docs ( ) ;
132132
133- // Automatically determine packages from the docs directory structure
134133export const packages = Array . from (
135134 new Set (
136135 Object . keys ( docs . topics )
137136 . map ( ( topic ) => topic . split ( '/' ) [ 1 ] )
138137 . filter ( Boolean )
139138 )
140- ) as const ;
139+ ) ;
141140
142- export type Package = ( typeof packages ) [ number ] ;
143-
144- const DOCUMENTATION_NAMES : Record < Package , string > = {
141+ const DOCUMENTATION_NAMES : Record < string , string > = {
145142 svelte : 'Svelte' ,
146143 kit : 'SvelteKit' ,
147144 cli : 'Svelte CLI'
148145} ;
149146
150- export function getDocumentationTitle ( type : Package ) : string {
147+ export function getDocumentationTitle ( type : string ) : string {
151148 return `This is the developer documentation for ${ DOCUMENTATION_NAMES [ type ] } .` ;
152149}
153150
154- export function getDocumentationStartTitle ( type : Package ) : string {
151+ export function getDocumentationStartTitle ( type : string ) : string {
155152 return `# Start of ${ DOCUMENTATION_NAMES [ type ] } documentation` ;
156153}
157154
158155export function filterDocsByPackage (
159156 allDocs : Record < string , string > ,
160- type : Package
157+ type : string
161158) : Record < string , string > {
162159 const filtered : Record < string , string > = { } ;
163160
Original file line number Diff line number Diff line change 66 filterDocsByPackage ,
77 generateLlmContent ,
88 getDocumentationTitle ,
9- packages ,
10- type Package
9+ packages
1110} from '$lib/server/content' ;
1211
1312export const prerender = true ;
@@ -19,17 +18,17 @@ export const entries: EntryGenerator = () => {
1918export const GET : RequestHandler = async ( { params } ) => {
2019 const packageType = params . path ;
2120
22- if ( ! packages . includes ( packageType as Package ) ) {
21+ if ( ! packages . includes ( packageType ) ) {
2322 error ( 404 , 'Not Found' ) ;
2423 }
2524
26- const filteredDocs = filterDocsByPackage ( documentsContent , packageType as Package ) ;
25+ const filteredDocs = filterDocsByPackage ( documentsContent , packageType ) ;
2726
2827 if ( Object . keys ( filteredDocs ) . length === 0 ) {
2928 error ( 404 , 'No documentation found for this package' ) ;
3029 }
3130
32- const PREFIX = `<SYSTEM>${ getDocumentationTitle ( packageType as Package ) } </SYSTEM>` ;
31+ const PREFIX = `<SYSTEM>${ getDocumentationTitle ( packageType ) } </SYSTEM>` ;
3332 const content = `${ PREFIX } \n\n${ generateLlmContent ( filteredDocs ) } ` ;
3433
3534 return new Response ( content , {
You can’t perform that action at this time.
0 commit comments