mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-01 16:00:29 +02:00
chore: normalize permalink to remove trailing slash if user permalink is not good
This commit is contained in:
parent
b99605f725
commit
20f6921b52
2 changed files with 10 additions and 8 deletions
|
@ -122,15 +122,17 @@ module.exports = async function processMetadata(
|
|||
|
||||
/*
|
||||
if user has own custom permalink defined in frontmatter
|
||||
e.g: :baseUrl:docsUrl/:langPart:versionPartendiliey/:id
|
||||
e.g: :baseUrl:docsUrl/:langPart/:versionPart/endiliey/:id
|
||||
*/
|
||||
if (metadata.permalink) {
|
||||
metadata.permalink = metadata.permalink
|
||||
.replace(/:baseUrl/, baseUrl)
|
||||
.replace(/:docsUrl/, docsUrl)
|
||||
.replace(/:langPart/, langPart)
|
||||
.replace(/:versionPart/, versionPart)
|
||||
.replace(/:id/, metadata.id);
|
||||
metadata.permalink = path.resolve(
|
||||
metadata.permalink
|
||||
.replace(/:baseUrl/, baseUrl)
|
||||
.replace(/:docsUrl/, docsUrl)
|
||||
.replace(/:langPart/, langPart)
|
||||
.replace(/:versionPart/, versionPart)
|
||||
.replace(/:id/, metadata.id)
|
||||
);
|
||||
} else {
|
||||
metadata.permalink = `${baseUrl}${docsUrl}/${langPart}${versionPart}${
|
||||
metadata.id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue