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() {
130
130
131
131
export const docs = create_docs ( ) ;
132
132
133
- // Automatically determine packages from the docs directory structure
134
133
export const packages = Array . from (
135
134
new Set (
136
135
Object . keys ( docs . topics )
137
136
. map ( ( topic ) => topic . split ( '/' ) [ 1 ] )
138
137
. filter ( Boolean )
139
138
)
140
- ) as const ;
139
+ ) ;
141
140
142
- export type Package = ( typeof packages ) [ number ] ;
143
-
144
- const DOCUMENTATION_NAMES : Record < Package , string > = {
141
+ const DOCUMENTATION_NAMES : Record < string , string > = {
145
142
svelte : 'Svelte' ,
146
143
kit : 'SvelteKit' ,
147
144
cli : 'Svelte CLI'
148
145
} ;
149
146
150
- export function getDocumentationTitle ( type : Package ) : string {
147
+ export function getDocumentationTitle ( type : string ) : string {
151
148
return `This is the developer documentation for ${ DOCUMENTATION_NAMES [ type ] } .` ;
152
149
}
153
150
154
- export function getDocumentationStartTitle ( type : Package ) : string {
151
+ export function getDocumentationStartTitle ( type : string ) : string {
155
152
return `# Start of ${ DOCUMENTATION_NAMES [ type ] } documentation` ;
156
153
}
157
154
158
155
export function filterDocsByPackage (
159
156
allDocs : Record < string , string > ,
160
- type : Package
157
+ type : string
161
158
) : Record < string , string > {
162
159
const filtered : Record < string , string > = { } ;
163
160
Original file line number Diff line number Diff line change 6
6
filterDocsByPackage ,
7
7
generateLlmContent ,
8
8
getDocumentationTitle ,
9
- packages ,
10
- type Package
9
+ packages
11
10
} from '$lib/server/content' ;
12
11
13
12
export const prerender = true ;
@@ -19,17 +18,17 @@ export const entries: EntryGenerator = () => {
19
18
export const GET : RequestHandler = async ( { params } ) => {
20
19
const packageType = params . path ;
21
20
22
- if ( ! packages . includes ( packageType as Package ) ) {
21
+ if ( ! packages . includes ( packageType ) ) {
23
22
error ( 404 , 'Not Found' ) ;
24
23
}
25
24
26
- const filteredDocs = filterDocsByPackage ( documentsContent , packageType as Package ) ;
25
+ const filteredDocs = filterDocsByPackage ( documentsContent , packageType ) ;
27
26
28
27
if ( Object . keys ( filteredDocs ) . length === 0 ) {
29
28
error ( 404 , 'No documentation found for this package' ) ;
30
29
}
31
30
32
- const PREFIX = `<SYSTEM>${ getDocumentationTitle ( packageType as Package ) } </SYSTEM>` ;
31
+ const PREFIX = `<SYSTEM>${ getDocumentationTitle ( packageType ) } </SYSTEM>` ;
33
32
const content = `${ PREFIX } \n\n${ generateLlmContent ( filteredDocs ) } ` ;
34
33
35
34
return new Response ( content , {
You can’t perform that action at this time.
0 commit comments