Skip to content

Commit

Permalink
[docs] Fix failing client-side navigation for /api routes (mui#28356)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored Sep 15, 2021
1 parent 2503a09 commit 5a0e7d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 6 additions & 2 deletions docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ module.exports = {
},
};
},
trailingSlash: true,
env: {
COMMIT_REF: process.env.COMMIT_REF,
ENABLE_AD: process.env.ENABLE_AD,
Expand Down Expand Up @@ -223,8 +222,13 @@ module.exports = {
return map;
},
reactStrictMode,
trailingSlash: true,
async rewrites() {
return [{ source: `/:lang(${LANGUAGES.join('|')})?/:rest*`, destination: '/:rest*' }];
return [
{ source: `/:lang(${LANGUAGES.join('|')})?/:rest*`, destination: '/:rest*' },
// Make sure to include the trailing slash if `trailingSlash` option is set
{ source: '/api/:rest*/', destination: '/api-docs/:rest*/' },
];
},
// Can be turned on when https://github.com/vercel/next.js/issues/24640 is fixed
optimizeFonts: false,
Expand Down
9 changes: 3 additions & 6 deletions docs/src/modules/components/MarkdownLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,12 @@ function handleClick(event) {
handleEvent(event, activeElement.getAttribute('href'));
}

let bound = false;

export default function MarkdownLinks() {
React.useEffect(() => {
if (bound) {
return;
}
bound = true;
document.addEventListener('click', handleClick);
return () => {
document.addEventListener('click', handleClick);
};
}, []);

return null;
Expand Down

0 comments on commit 5a0e7d9

Please sign in to comment.