Skip to content

Commit ea0c646

Browse files
committed
clean up
1 parent e51cf30 commit ea0c646

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

apps/svelte.dev/src/lib/server/content.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,34 +130,31 @@ function create_docs() {
130130

131131
export const docs = create_docs();
132132

133-
// Automatically determine packages from the docs directory structure
134133
export 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

158155
export function filterDocsByPackage(
159156
allDocs: Record<string, string>,
160-
type: Package
157+
type: string
161158
): Record<string, string> {
162159
const filtered: Record<string, string> = {};
163160

apps/svelte.dev/src/routes/docs/[...path]/llms.txt/+server.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import {
66
filterDocsByPackage,
77
generateLlmContent,
88
getDocumentationTitle,
9-
packages,
10-
type Package
9+
packages
1110
} from '$lib/server/content';
1211

1312
export const prerender = true;
@@ -19,17 +18,17 @@ export const entries: EntryGenerator = () => {
1918
export 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, {

0 commit comments

Comments
 (0)