From 9ad06b641e45bd1c05a8c9464a058754b337fe7a Mon Sep 17 00:00:00 2001 From: Puru Vijay Date: Sat, 1 Apr 2023 12:13:07 +0530 Subject: [PATCH] Reduce duplication in redirect regex --- sites/svelte.dev/src/routes/docs/+page.svelte | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/sites/svelte.dev/src/routes/docs/+page.svelte b/sites/svelte.dev/src/routes/docs/+page.svelte index a79d74f536..c83e4d3243 100644 --- a/sites/svelte.dev/src/routes/docs/+page.svelte +++ b/sites/svelte.dev/src/routes/docs/+page.svelte @@ -137,16 +137,13 @@ const pages_regex_map = new Map([ // Basic ones [/(before-we-begin|getting-started)$/i, 'introduction'], - [/(component-format)$/i, 'dot-svelte-files'], - [/template-syntax$/i, 'dot-svelte-files'], + [/(component-format|template-syntax)$/i, 'dot-svelte-files'], [/run-time$/i, 'svelte'], [/compile-time$/i, 'svelte-compiler'], [/(accessibility-warnings)$/i, '$1'], // component-format- - [/component-format-(style)$/i, 'dot-svelte-files#$1'], - [/component-format-(script)$/i, 'dot-svelte-files#$1'], - [/component-format-(script-context-module)$/i, 'dot-svelte-files#$1'], + [/component-format-(script|style|script-context-module)$/i, 'dot-svelte-files#$1'], [/component-format-(?:script)(?:-?(.*))$/i, 'dot-svelte-files#$1'], // template-syntax @@ -155,16 +152,20 @@ [/template-syntax-(?:slot)-?(.*)/i, 'special-elements#$1'], [/template-syntax-(if|each|await|key)$/i, 'logic-blocks#$1'], [/template-syntax-(const|debug|html)$/i, 'special-tags#$1'], + [ + /template-syntax-(tags|attributes-and-props|text-expressions|comments)$/i, + 'dot-svelte-files#$1', + ], // !!!! This one should stay at the bottom of `template-syntax`, or it may end up hijacking logic blocks and special tags - [/template-syntax-(.+)/i, 'dot-svelte-files#$1'], + [/template-syntax-(.+)/i, 'special-elements#$1'], // run-time [/run-time-(svelte-(?:store|motion|transition|animate))-?(.*)/i, '$1#$2'], - [/run-time-(svelte-easing)$/i, '$1'], [/run-time-(client-side-component-api)-?(.*)/i, '$1#$2'], - [/run-time-(server-side-component-api)$/i, '$1'], - [/run-time-(custom-element-api)$/i, '$1'], - [/run-time-(svelte-register)$/i, '$1'], + [ + /run-time-(svelte-easing|server-side-component-api|custom-element-api|svelte-register)$/i, + '$1', + ], // Catch all, should be at the end or will include store, motion, transition and other modules starting with svelte [/run-time-(svelte)(?:-(.+))?/i, '$1#$2'],