Skip to content

Commit

Permalink
try some link replace voodoo
Browse files Browse the repository at this point in the history
  • Loading branch information
goodroot committed Dec 12, 2024
1 parent 2ed0e5b commit 4e43307
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const config = {
}
},
}),
require.resolve("./plugins/transform-urls/index"),
require.resolve("./plugins/fetch-latest-release/index"),
require.resolve("./plugins/fetch-repo/index"),
require.resolve("./plugins/remote-repo-example/index"),
Expand Down Expand Up @@ -140,13 +141,12 @@ const config = {
[
"@docusaurus/preset-classic",
{

blog: false,
docs: {
include: ["**/*!(.partial).{md,mdx}"],
exclude: ["/glossary/"],
path: "documentation",
routeBasePath: "/",
routeBasePath: '/',
editUrl: ({ docPath }) => {
return `https://github.com/questdb/documentation/documentation/edit/main/${docPath}`
},
Expand Down
21 changes: 21 additions & 0 deletions plugins/transform-urls/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const visit = require('unist-util-visit')

module.exports = function(context, options) {
const isPreviews = process.env.NETLIFY && process.env.CONTEXT === 'deploy-preview'

return {
name: 'transform-urls-plugin',
remarkPlugins: [
() => {
return (tree) => {
visit(tree, 'link', (node) => {
// Only transform internal links that start with /docs/
if (node.url.startsWith('/docs/') && isPreviews) {
node.url = node.url.replace(/^\/docs\//, '/')
}
})
}
}
]
}
}

0 comments on commit 4e43307

Please sign in to comment.