|
1 | 1 | import type { RequestHandler } from './$types';
|
2 |
| -import { documentsContent, getDocumentationStartTitle, sortPaths } from '$lib/server/content'; |
| 2 | +import { documentsContent, generateCombinedContent } from '$lib/server/content'; |
3 | 3 |
|
4 | 4 | const PREFIX = 'This is the abridged developer documentation for Svelte and SvelteKit.';
|
5 | 5 |
|
6 | 6 | export const GET: RequestHandler = async () => {
|
7 |
| - let content = `${PREFIX}\n\n`; |
8 |
| - |
9 |
| - const paths = sortPaths(Object.keys(documentsContent)); |
10 |
| - |
11 |
| - let currentSection = ''; |
12 |
| - |
13 |
| - for (const path of paths) { |
14 |
| - let section = ''; |
15 |
| - if (path.includes('/docs/svelte/')) section = getDocumentationStartTitle('svelte'); |
16 |
| - else if (path.includes('/docs/kit/')) section = getDocumentationStartTitle('kit'); |
17 |
| - else if (path.includes('/docs/cli/')) section = getDocumentationStartTitle('cli'); |
18 |
| - else continue; |
19 |
| - |
20 |
| - if (section !== currentSection) { |
21 |
| - if (currentSection) content += '\n'; |
22 |
| - content += `${section}\n\n`; |
23 |
| - currentSection = section; |
24 |
| - } |
25 |
| - |
26 |
| - content += `## ${path.replace('../../../content/', '')}\n\n`; |
27 |
| - content += documentsContent[path]; |
28 |
| - content += '\n'; |
29 |
| - } |
30 |
| - |
31 |
| - const headers: HeadersInit = { |
32 |
| - 'Content-Type': 'text/plain; charset=utf-8', |
33 |
| - 'Cache-Control': 'public, max-age=3600' |
34 |
| - }; |
| 7 | + const content = `${PREFIX}\n\n${generateCombinedContent(documentsContent)}`; |
35 | 8 |
|
36 | 9 | return new Response(content, {
|
37 | 10 | status: 200,
|
38 |
| - headers |
| 11 | + headers: { |
| 12 | + 'Content-Type': 'text/plain; charset=utf-8', |
| 13 | + 'Cache-Control': 'public, max-age=3600' |
| 14 | + } |
39 | 15 | });
|
40 | 16 | };
|
41 | 17 |
|
|
0 commit comments