Refactor route generation in starlight-ghostcms integration

This commit is contained in:
Adam Matthiesen 2024-03-07 04:05:50 -08:00
parent 5e73f12070
commit b6ba6fedc1
1 changed files with 7 additions and 4 deletions

View File

@ -32,14 +32,17 @@ export default defineIntegration({
prerender: true, prerender: true,
}); });
}; };
const sanitisedRoute = options.route
.replace(/^\//, '')
.replace(/\/$/, '');
makeRoute(`${options.route}`, makeRoute(`${sanitisedRoute}`,
"index.astro"); "index.astro");
makeRoute(`${options.route}/[slug]`, makeRoute(`${sanitisedRoute}/[slug]`,
"[slug].astro"); "[slug].astro");
makeRoute(`${options.route}/about`, makeRoute(`${sanitisedRoute}/about`,
"about.astro"); "about.astro");
makeRoute(`${options.route}/authors`, makeRoute(`${sanitisedRoute}/authors`,
"authors.astro"); "authors.astro");
makeRoute("rss.xml", makeRoute("rss.xml",
"rss.xml.ts"); "rss.xml.ts");