Skip to content

Commit

Permalink
try before remark instead
Browse files Browse the repository at this point in the history
  • Loading branch information
goodroot committed Dec 12, 2024
1 parent 4e43307 commit 1fefc3a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.
4 changes: 3 additions & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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}`
},
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
34 changes: 22 additions & 12 deletions plugins/transform-urls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '/')
}
})
}
},
],
],
}
}
12 changes: 0 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14266,11 +14266,6 @@ use-sidecar@^1.1.2:
detect-node-es "^1.1.0"
tslib "^2.0.0"

[email protected]:
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"
Expand Down Expand Up @@ -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==

[email protected]:
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"
Expand Down

0 comments on commit 1fefc3a

Please sign in to comment.