Skip to content

Commit

Permalink
fix: account for section-less pages during code redirects (sveltejs#990)
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm authored Dec 11, 2024
1 parent 7487ef1 commit b167c13
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/svelte.dev/src/routes/e/tmp/codes.json/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ const codes: Record<string, Record<string, string[]>> = {};

for (const page of reference) {
const grouped: Record<string, string[]> = {};
const sections = page.body.split(/(^|\n)## /g).slice(1);
const sections = page.body.split(/(^|\n)## /g);

if (sections.length > 1) {
sections.shift();
}

for (const section of sections) {
const lines = section.slice(section.startsWith('\n') ? 1 : 0).split('\n');
Expand Down

0 comments on commit b167c13

Please sign in to comment.