mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-02 19:03:38 +02:00
feat(pages): Support frontMatter.slug
like docs and blog plugins (#11088)
This commit is contained in:
parent
ac0a6f7d5b
commit
5b944d6b64
8 changed files with 23 additions and 9 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue