mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +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
|
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) {
|
if (metadata.permalink) {
|
||||||
metadata.permalink = metadata.permalink
|
metadata.permalink = path.resolve(
|
||||||
.replace(/:baseUrl/, baseUrl)
|
metadata.permalink
|
||||||
.replace(/:docsUrl/, docsUrl)
|
.replace(/:baseUrl/, baseUrl)
|
||||||
.replace(/:langPart/, langPart)
|
.replace(/:docsUrl/, docsUrl)
|
||||||
.replace(/:versionPart/, versionPart)
|
.replace(/:langPart/, langPart)
|
||||||
.replace(/:id/, metadata.id);
|
.replace(/:versionPart/, versionPart)
|
||||||
|
.replace(/:id/, metadata.id)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
metadata.permalink = `${baseUrl}${docsUrl}/${langPart}${versionPart}${
|
metadata.permalink = `${baseUrl}${docsUrl}/${langPart}${versionPart}${
|
||||||
metadata.id
|
metadata.id
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
id: permalink
|
id: permalink
|
||||||
title: Permalink
|
title: Permalink
|
||||||
permalink: :baseUrl:docsUrl/:langPart:versionPartendiliey/:id
|
permalink: :baseUrl:docsUrl/:langPart/:versionPart/endiliey/:id
|
||||||
---
|
---
|
||||||
|
|
||||||
This has a different permalink
|
This has a different permalink
|
Loading…
Add table
Add a link
Reference in a new issue