diff --git a/docusaurus.config.js b/docusaurus.config.js index 2ced3fc3..7effd5da 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -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"), @@ -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}` }, diff --git a/plugins/transform-urls/index.js b/plugins/transform-urls/index.js new file mode 100644 index 00000000..01c4e0fb --- /dev/null +++ b/plugins/transform-urls/index.js @@ -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\//, '/') + } + }) + } + } + ] + } +} \ No newline at end of file