feat(pages): Support frontMatter.slug like docs and blog plugins (#11088)

This commit is contained in:
Sébastien Lorber 2025-04-11 14:44:19 +02:00 committed by GitHub
parent ac0a6f7d5b
commit 5b944d6b64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 23 additions and 9 deletions

View file

@ -106,12 +106,13 @@ async function processPageSourceFile(
const source = path.join(contentPath, relativeSource);
const aliasedSourcePath = aliasedSitePath(source, siteDir);
const permalink = normalizeUrl([
baseUrl,
options.routeBasePath,
encodePath(fileToPath(relativeSource)),
]);
const filenameSlug = encodePath(fileToPath(relativeSource));
if (!isMarkdownSource(relativeSource)) {
// For now, slug can't be customized for JSX pages
const slug = filenameSlug;
const permalink = normalizeUrl([baseUrl, options.routeBasePath, slug]);
return {
type: 'jsx',
permalink,
@ -131,6 +132,9 @@ async function processPageSourceFile(
});
const frontMatter = validatePageFrontMatter(unsafeFrontMatter);
const slug = frontMatter.slug ?? filenameSlug;
const permalink = normalizeUrl([baseUrl, options.routeBasePath, slug]);
const pagesDirPath = await getFolderContainingFile(
getContentPathList(contentPaths),
relativeSource,