diff --git a/docusaurus.config.js b/docusaurus.config.js index 7effd5da..26bfcc27 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -50,7 +50,6 @@ 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"), @@ -147,6 +146,9 @@ const config = { exclude: ["/glossary/"], path: "documentation", routeBasePath: '/', + beforeDefaultRemarkPlugins: [ + require('./plugins/transform-urls'), + ], editUrl: ({ docPath }) => { return `https://github.com/questdb/documentation/documentation/edit/main/${docPath}` }, diff --git a/package.json b/package.json index 184dceb5..33dec9f2 100644 --- a/package.json +++ b/package.json @@ -87,8 +87,7 @@ "tailwindcss": "3.4.15", "typescript": "~5.6.3", "webpack": "5.96.1", - "webpack-manifest-plugin": "5.0.0", - "zustand": "4.5.0" + "webpack-manifest-plugin": "5.0.0" }, "browserslist": { "production": [ diff --git a/plugins/transform-urls/index.js b/plugins/transform-urls/index.js index 01c4e0fb..76baa6e0 100644 --- a/plugins/transform-urls/index.js +++ b/plugins/transform-urls/index.js @@ -5,17 +5,27 @@ module.exports = function(context, options) { 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\//, '/') - } - }) - } - } - ] + beforeDefaultRemarkPlugins: [ + [ + () => { + return (tree) => { + if (!isPreviews) return + + visit(tree, 'link', (node) => { + if (node.url.startsWith('/docs/')) { + node.url = node.url.replace(/^\/docs\//, '/') + } + }) + + // Also handle inline code and code blocks that might contain URLs + visit(tree, ['inlineCode', 'code'], (node) => { + if (typeof node.value === 'string') { + node.value = node.value.replace(/\/docs\//g, '/') + } + }) + } + }, + ], + ], } } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index b1c1047a..3dc4e77c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14266,11 +14266,6 @@ use-sidecar@^1.1.2: detect-node-es "^1.1.0" tslib "^2.0.0" -use-sync-external-store@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz#7dbefd6ef3fe4e767a0cf5d7287aacfb5846928a" - integrity sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA== - util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" @@ -14966,13 +14961,6 @@ yocto-queue@^1.0.0: resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-1.1.1.tgz#fef65ce3ac9f8a32ceac5a634f74e17e5b232110" integrity sha512-b4JR1PFR10y1mKjhHY9LaGo6tmrgjit7hxVIeAmyMw3jegXR4dhYqLaQF5zMXZxY7tLpMyJeLjr1C4rLmkVe8g== -zustand@4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/zustand/-/zustand-4.5.0.tgz#141354af56f91de378aa6c4b930032ab338f3ef0" - integrity sha512-zlVFqS5TQ21nwijjhJlx4f9iGrXSL0o/+Dpy4txAP22miJ8Ti6c1Ol1RLNN98BMib83lmDH/2KmLwaNXpjrO1A== - dependencies: - use-sync-external-store "1.2.0" - zwitch@^2.0.0: version "2.0.4" resolved "https://registry.yarnpkg.com/zwitch/-/zwitch-2.0.4.tgz#c827d4b0acb76fc3e685a4c6ec2902d51070e9d7"