Skip to content

Commit

Permalink
fix: broken internal links when there is trailing slash (#290)
Browse files Browse the repository at this point in the history
* chore: fix issue with internal links when there is trailing slash in the url

* chore: rollback docusaurus -> 2.4.1
  • Loading branch information
tuan-pham authored May 7, 2024
1 parent ac902c1 commit 6861702
Show file tree
Hide file tree
Showing 3 changed files with 2,478 additions and 1,425 deletions.
11 changes: 8 additions & 3 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ module.exports = {
favicon: "img/favicon.ico",
organizationName: "PactFlow", // Usually your GitHub org/user name.
projectName: "doc-site", // Usually your repo name.
scripts: [
{
src: '/js/fix-location.js',
async: false,
defer: false,
},
],
themeConfig: {
// announcementBar: {
// id: 'announcement-bar',
Expand Down Expand Up @@ -89,7 +96,7 @@ module.exports = {
}
},
cleanUrl: true,
trailingSlash: true,
trailingSlash: false,
algolia: {
contextualSearch: false,
appId: "LY8MHW6MWQ",
Expand All @@ -100,8 +107,6 @@ module.exports = {
metadata: [
{ name: "docsearch:docusaurus_tag", content: "docs-default-current" },
],


prism: {
// default list https://github.com/FormidableLabs/prism-react-renderer/blob/master/src/vendor/prism/includeLangs.js
// additional supported langs https://prismjs.com/#supported-languages
Expand Down
5 changes: 5 additions & 0 deletions website/static/js/fix-location.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Workaround to fix Docusaurus issue with internal links when there is a trailing slash in the URL
// For more info: https://github.com/facebook/docusaurus/issues/2394
if (window && window.location && window.location.pathname.endsWith('/') && window.location.pathname !== '/') {
window.history.replaceState('', '', window.location.pathname.substr(0, window.location.pathname.length - 1))
}
Loading

0 comments on commit 6861702

Please sign in to comment.