Skip to content

Commit

Permalink
upgrade to docusaurus 3 (#9820)
Browse files Browse the repository at this point in the history
* update packages

* add plugin to strip autolinks in code blocks

* fix all the documentation for MDXv3

* remove check-docusaurus-versions

in docusaurus 3 this is now a hard error, not just a warning

* port upstream change to Curl component

fixes performing the 'execute' action when pressing enter
  • Loading branch information
chris48s authored Mar 23, 2024
1 parent df8049a commit bd3a11b
Show file tree
Hide file tree
Showing 46 changed files with 5,383 additions and 3,907 deletions.
16 changes: 0 additions & 16 deletions .github/scripts/check-docusaurus-versions.sh

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/check-docusaurus-versions.yml

This file was deleted.

10 changes: 10 additions & 0 deletions frontend/docusaurus.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const lightCodeTheme = require('prism-react-renderer').themes.github
const darkCodeTheme = require('prism-react-renderer').themes.dracula
const stripCodeBlockLinks = require('./src/plugins/strip-code-block-links')

/** @type {import('@docusaurus/types').Config} */
const config = {
Expand All @@ -24,6 +25,14 @@ const config = {
],
],

markdown: {
mdx1Compat: {
comments: true,
admonitions: true,
headingIds: true,
},
},

presets: [
[
'docusaurus-preset-openapi',
Expand All @@ -43,6 +52,7 @@ const config = {
api: {
path: 'categories',
routeBasePath: 'badges',
rehypePlugins: [stripCodeBlockLinks],
},
}),
],
Expand Down
14 changes: 5 additions & 9 deletions frontend/src/pages/community.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ Shields.io is possible thanks to the people and companies who donate money, serv

<ul>
<li>
<a href="https://nodeping.com/">
NodePing
</a>
<a href="https://nodeping.com/">NodePing</a>
</li>
<li>
<a href="https://sentry.io/">
Sentry
</a>
<a href="https://sentry.io/">Sentry</a>
</li>
</ul>

Expand All @@ -24,7 +20,7 @@ Shields.io is possible thanks to the people and companies who donate money, serv
<p>
<object
data="https://opencollective.com/shields/tiers/sponsor.svg?avatarHeight=80&width=600"
class="opencollective-image"
className="opencollective-image"
></object>
</p>

Expand All @@ -35,7 +31,7 @@ Shields.io is possible thanks to the people and companies who donate money, serv
<p>
<object
data="https://opencollective.com/shields/tiers/backer.svg?width=600"
class="opencollective-image">
className="opencollective-image">
</object>
</p>

Expand All @@ -46,7 +42,7 @@ Shields.io is possible thanks to the people and companies who donate money, serv
<p>
<object
data="https://opencollective.com/shields/contributors.svg?width=600"
class="opencollective-image"
className="opencollective-image"
></object>
</p>

Expand Down
30 changes: 30 additions & 0 deletions frontend/src/plugins/strip-code-block-links.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const { visit } = require('unist-util-visit')

function stripCodeBlockLinks() {
/*
Docusaurus 3 uses [remark-gfm](https://github.com/remarkjs/remark-gfm)
One of the "features" of remark-gfm is that it automatically looks for URLs
and email addresses, and automatically wraps them in <a> tags.
This happens even if the URL is inside a <code> block.
This behaviour is
a) mostly unhelpful and
b) non-configurable
This plugin removes <a> tags which appear inside a <code> block.
*/
return tree => {
visit(tree, ['mdxJsxTextElement', 'mdxJsxFlowElement', 'element'], node => {
if (node.name === 'code' || node.tagName === 'code') {
const links = node.children.filter(child => child.tagName === 'a')
links.forEach(link => {
const linkText = link.children.map(child => child.value).join('')
const linkIndex = node.children.indexOf(link)
node.children.splice(linkIndex, 1, { type: 'text', value: linkText })
})
}
})
}
}

module.exports = stripCodeBlockLinks
1 change: 1 addition & 0 deletions frontend/src/theme/ApiDemoPanel/Curl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ function Curl({ postman, codeSamples }) {
)}
key={lang.tabName || lang.label}
onClick={() => setLanguage(lang)}
type="button"
>
{lang.tabName || lang.label}
</button>
Expand Down
Loading

0 comments on commit bd3a11b

Please sign in to comment.