From cf476817ffd9a04d03c1865e38192905c47fd13d Mon Sep 17 00:00:00 2001 From: paoloricciuti Date: Fri, 26 Sep 2025 23:25:21 +0200 Subject: [PATCH 1/5] feat: add `docs/sections` endpoint to list all docs sections --- .../src/routes/docs/sections/+server.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 apps/svelte.dev/src/routes/docs/sections/+server.ts diff --git a/apps/svelte.dev/src/routes/docs/sections/+server.ts b/apps/svelte.dev/src/routes/docs/sections/+server.ts new file mode 100644 index 0000000000..c3145e22a2 --- /dev/null +++ b/apps/svelte.dev/src/routes/docs/sections/+server.ts @@ -0,0 +1,21 @@ +import { docs } from '$lib/server/content'; +import { json } from '@sveltejs/kit'; + +export const prerender = true; + +export function GET({ url: { searchParams } }) { + const complete = searchParams.has('complete'); + // by default we return a light version with just the title, the slug and the file path + // but the user can opt in to get the complete content by adding ?complete + if (complete) { + return json(docs.pages); + } + return json( + Object.fromEntries( + Object.entries(docs.pages).map(([key, page]) => [ + key, + { metadata: { title: page.metadata.title }, slug: page.slug, file: page.file } + ]) + ) + ); +} From d52a70faf794f0f5698bef596c6135ce5558a52c Mon Sep 17 00:00:00 2001 From: paoloricciuti Date: Fri, 26 Sep 2025 23:30:58 +0200 Subject: [PATCH 2/5] fix: remove query param --- apps/svelte.dev/src/routes/docs/sections/+server.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/apps/svelte.dev/src/routes/docs/sections/+server.ts b/apps/svelte.dev/src/routes/docs/sections/+server.ts index c3145e22a2..df07bd4a6e 100644 --- a/apps/svelte.dev/src/routes/docs/sections/+server.ts +++ b/apps/svelte.dev/src/routes/docs/sections/+server.ts @@ -3,13 +3,7 @@ import { json } from '@sveltejs/kit'; export const prerender = true; -export function GET({ url: { searchParams } }) { - const complete = searchParams.has('complete'); - // by default we return a light version with just the title, the slug and the file path - // but the user can opt in to get the complete content by adding ?complete - if (complete) { - return json(docs.pages); - } +export function GET() { return json( Object.fromEntries( Object.entries(docs.pages).map(([key, page]) => [ From 2cb22386a1e9cae0d225591dc729346aff2f929a Mon Sep 17 00:00:00 2001 From: paoloricciuti Date: Sun, 28 Sep 2025 15:57:07 +0200 Subject: [PATCH 3/5] chore: rename to `sections.json` and add `use_cases` metadata --- .../src/routes/docs/{sections => sections.json}/+server.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) rename apps/svelte.dev/src/routes/docs/{sections => sections.json}/+server.ts (64%) diff --git a/apps/svelte.dev/src/routes/docs/sections/+server.ts b/apps/svelte.dev/src/routes/docs/sections.json/+server.ts similarity index 64% rename from apps/svelte.dev/src/routes/docs/sections/+server.ts rename to apps/svelte.dev/src/routes/docs/sections.json/+server.ts index df07bd4a6e..0ed7a1ea06 100644 --- a/apps/svelte.dev/src/routes/docs/sections/+server.ts +++ b/apps/svelte.dev/src/routes/docs/sections.json/+server.ts @@ -8,7 +8,11 @@ export function GET() { Object.fromEntries( Object.entries(docs.pages).map(([key, page]) => [ key, - { metadata: { title: page.metadata.title }, slug: page.slug, file: page.file } + { + metadata: { title: page.metadata.title, use_cases: page.metadata.use_cases }, + slug: page.slug, + file: page.file + } ]) ) ); From 50ae8140ff2a7767501ad2c0352665835e03ad01 Mon Sep 17 00:00:00 2001 From: paoloricciuti Date: Wed, 1 Oct 2025 00:04:55 +0200 Subject: [PATCH 4/5] fix: add `/experimental` to route --- .../src/routes/docs/{ => experimental}/sections.json/+server.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename apps/svelte.dev/src/routes/docs/{ => experimental}/sections.json/+server.ts (100%) diff --git a/apps/svelte.dev/src/routes/docs/sections.json/+server.ts b/apps/svelte.dev/src/routes/docs/experimental/sections.json/+server.ts similarity index 100% rename from apps/svelte.dev/src/routes/docs/sections.json/+server.ts rename to apps/svelte.dev/src/routes/docs/experimental/sections.json/+server.ts From 9eee96a051e9ef148d77ce35684ba077c971ddaa Mon Sep 17 00:00:00 2001 From: paoloricciuti Date: Wed, 1 Oct 2025 23:40:17 +0200 Subject: [PATCH 5/5] fix: remove unused `file` --- .../src/routes/docs/experimental/sections.json/+server.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/svelte.dev/src/routes/docs/experimental/sections.json/+server.ts b/apps/svelte.dev/src/routes/docs/experimental/sections.json/+server.ts index 0ed7a1ea06..35ef1ce6f3 100644 --- a/apps/svelte.dev/src/routes/docs/experimental/sections.json/+server.ts +++ b/apps/svelte.dev/src/routes/docs/experimental/sections.json/+server.ts @@ -10,8 +10,7 @@ export function GET() { key, { metadata: { title: page.metadata.title, use_cases: page.metadata.use_cases }, - slug: page.slug, - file: page.file + slug: page.slug } ]) )