docusaurus/assets/js/575718d1.3db89808.js
2025-03-24 14:34:53 +00:00

1 line
No EOL
32 KiB
JavaScript

"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["19724"],{51215:function(e,s,n){n.d(s,{Z:()=>r});let r=n.p+"assets/images/social-card-75819f68ecbb579fe176843bb2e3df82.png"},87390:function(e,s,n){n.d(s,{Z:()=>r});let r=n.p+"assets/images/social-card-75819f68ecbb579fe176843bb2e3df82.png"},38421:function(e,s,n){n.r(s),n.d(s,{assets:()=>l,contentTitle:()=>c,default:()=>h,frontMatter:()=>o,metadata:()=>r,toc:()=>d});var r=n(80931),t=n(85893),i=n(80980),a=n(51118);let o={title:"Announcing Docusaurus 3.0",authors:["slorber"],tags:["release"],image:"./img/social-card.png",date:new Date("2023-10-31T00:00:00.000Z")},c=void 0,l={image:n(51215).Z,authorsImageUrls:[void 0]},d=[{value:"Breaking changes",id:"breaking-changes",level:2},{value:"Highlights",id:"highlights",level:2},{value:"Markdown",id:"markdown",level:3},{value:"ESM and TypeScript configs",id:"esm-ts-configs",level:3},{value:"Unlisted content",id:"unlisted-content",level:3},{value:"React 18",id:"react-18",level:3},{value:"Automatic JSX runtime",id:"automatic-jsx-runtime",level:3},{value:"Debug builds",id:"debug-builds",level:3},{value:"TypeScript",id:"typescript",level:3},{value:"Code blocks",id:"code-blocks",level:3},{value:"Mermaid diagrams",id:"mermaid-diagrams",level:3},{value:"Query-string data attributes",id:"query-string-data-attributes",level:3},{value:"Other features",id:"other-features",level:3},{value:"Conclusion",id:"conclusion",level:2}];function u(e){let s={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",img:"img",li:"li",mermaid:"mermaid",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.a)(),...e.components},{Details:r}=s;return r||function(e,s){throw Error("Expected "+(s?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}("Details",!0),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(s.p,{children:["Today, we are happy to ",(0,t.jsx)(s.strong,{children:"announce Docusaurus 3.0"}),"! \uD83E\uDD73"]}),"\n",(0,t.jsxs)(s.p,{children:["At ",(0,t.jsx)(s.a,{href:"https://opensource.fb.com/",children:(0,t.jsx)(s.strong,{children:"Meta Open Source"})}),", we believe Docusaurus will help you build the ",(0,t.jsx)(s.strong,{children:"best documentation websites"})," with ",(0,t.jsx)(s.strong,{children:"minimal effort"}),", letting you ",(0,t.jsx)(s.strong,{children:"focus on what really matters"}),": writing the content."]}),"\n",(0,t.jsxs)(s.p,{children:["This is a new ",(0,t.jsx)(s.strong,{children:"major version"})," of Docusaurus, coming with ",(0,t.jsx)(s.strong,{children:"new exciting features"})," and upgraded dependencies."]}),"\n",(0,t.jsxs)(s.p,{children:["In line with the ",(0,t.jsx)(s.a,{href:"https://semver.org/",children:(0,t.jsx)(s.strong,{children:"Semantic Versioning"})})," principles, this release includes ",(0,t.jsx)(s.strong,{children:"breaking changes"})," we documented thoroughly in the ",(0,t.jsx)(s.a,{href:"/docs/migration/v3/",children:(0,t.jsx)(s.strong,{children:"v3 upgrade guide"})}),". Breaking changes can be bothersome, but they are necessary to set the ground for a ",(0,t.jsx)(s.strong,{children:"new wave of Docusaurus features"})," we plan to implement."]}),"\n",(0,t.jsx)(s.p,{children:(0,t.jsx)(s.img,{alt:"v3.0 social-card image",src:n(87390).Z+"",width:"1200",height:"600"})}),"\n","\n",(0,t.jsxs)(s.p,{children:["We initially planned to release more frequent major versions, but Docusaurus v3 has taken longer than expected. Among the breaking changes that we accrued, ",(0,t.jsx)(s.strong,{children:"upgrading to MDX v3"})," is probably the main challenge to the adoption of this new version. We went the extra mile to make this upgrade as easy as possible, notably by adding ",(0,t.jsx)(s.a,{href:"/docs/api/docusaurus-config#markdown",children:"compatibility options for MDX v1"}),"."]}),"\n",(0,t.jsx)(s.p,{children:"The simplest sites will only need to upgrade a few npm dependencies. For more complex sites, we came up with a few strategies that can help you upgrade more confidently:"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.a,{href:"/blog/preparing-your-site-for-docusaurus-v3",children:"Prepare your site"})," ahead of time, incrementally, while staying on Docusaurus v2"]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.a,{href:"/blog/upgrading-frontend-dependencies-with-confidence-using-visual-regression-testing",children:"Set up visual regression tests"})," to catch unexpected visual changes happening during the upgrade"]}),"\n"]}),"\n",(0,t.jsx)(s.admonition,{title:"About Docusaurus v2",type:"info",children:(0,t.jsxs)(s.p,{children:["According to our ",(0,t.jsx)(s.a,{href:"/community/release-process#stable-version",children:"release process"}),", Docusaurus v2 has now entered ",(0,t.jsx)(s.strong,{children:"maintenance mode"}),". It will only receive support for major security issues for 3 months, until 31 January 2024. It is recommended to upgrade within that time frame to v3."]})}),"\n","\n",(0,t.jsx)(s.h2,{id:"breaking-changes",children:"Breaking changes"}),"\n",(0,t.jsxs)(s.p,{children:["This section only gives you a quick glance. All the breaking changes are thoroughly documented in the ",(0,t.jsx)(s.a,{href:"/docs/migration/v3",children:(0,t.jsx)(s.strong,{children:"v3 upgrade guide"})}),"."]}),"\n",(0,t.jsx)(s.p,{children:"Docusaurus v3 upgraded a few dependencies to new major versions, each coming with its own breaking changes:"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsx)(s.li,{children:"Node.js v16 \u27A1\uFE0F v18"}),"\n",(0,t.jsx)(s.li,{children:"React v17 \u27A1\uFE0F v18"}),"\n",(0,t.jsx)(s.li,{children:"MDX v1 \u27A1\uFE0F v3"}),"\n",(0,t.jsx)(s.li,{children:"TypeScript v4 \u27A1\uFE0F v5"}),"\n",(0,t.jsx)(s.li,{children:"prism-react-renderer v1 \u27A1\uFE0F v2"}),"\n",(0,t.jsx)(s.li,{children:"react-live v2 \u27A1\uFE0F v4"}),"\n",(0,t.jsx)(s.li,{children:"Mermaid v9 \u27A1\uFE0F v10"}),"\n",(0,t.jsx)(s.li,{children:"import-fresh v3 \u27A1\uFE0F jiti v1"}),"\n",(0,t.jsx)(s.li,{children:"remark-emoji v2 \u27A1\uFE0F v4"}),"\n"]}),"\n",(0,t.jsxs)(s.p,{children:["A typical ",(0,t.jsx)(s.code,{children:"package.json"})," dependency upgrade looks like:"]}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-diff",metastring:'title="package.json"',children:' {\n "dependencies": {\n // upgrade to Docusaurus v3\n- "@docusaurus/core": "2.4.3",\n- "@docusaurus/preset-classic": "2.4.3",\n+ "@docusaurus/core": "3.0.0",\n+ "@docusaurus/preset-classic": "3.0.0",\n // upgrade to MDX v3\n- "@mdx-js/react": "^1.6.22",\n+ "@mdx-js/react": "^3.0.0",\n // upgrade to prism-react-renderer v2.0+\n- "prism-react-renderer": "^1.3.5",\n+ "prism-react-renderer": "^2.1.0",\n // upgrade to React v18.0+\n- "react": "^17.0.2",\n- "react-dom": "^17.0.2"\n+ "react": "^18.2.0",\n+ "react-dom": "^18.2.0"\n },\n "devDependencies": {\n // upgrade Docusaurus dev dependencies to v3\n- "@docusaurus/module-type-aliases": "2.4.3",\n- "@docusaurus/types": "2.4.3"\n+ "@docusaurus/module-type-aliases": "3.0.0",\n+ "@docusaurus/types": "3.0.0"\n }\n "engines": {\n // require Node.js 18.0+\n- "node": ">=16.14"\n+ "node": ">=18.0"\n }\n }\n'})}),"\n",(0,t.jsx)(s.p,{children:"Apart from MDX v3, most breaking changes coming with those upgraded dependencies have been handled internally for you: most of the time, you shouldn't have to do anything. Outside of dependencies, the only functional breaking changes coming explicitly from the Docusaurus codebase are:"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/9189",children:"#9189"}),": new default blog RSS feed limit of 20 entries"]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/9308",children:"#9308"}),": fix and re-introduce the ",(0,t.jsx)(s.code,{children:":::warning"})," admonition, deprecate ",(0,t.jsx)(s.code,{children:":::caution"})]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/9310",children:"#9310"}),": remove the legacy versioned sidebar id prefix, used for sites versioned before ",(0,t.jsx)(s.code,{children:"v2.0.0-beta.10"})," (December 2021)"]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/7966",children:"#7966"}),": refactor docs theme components, eventually requiring to you re-swizzle them"]}),"\n"]}),"\n",(0,t.jsx)(s.h2,{id:"highlights",children:"Highlights"}),"\n",(0,t.jsxs)(s.p,{children:["Below is a non-exhaustive list of new useful features coming with this new version. All the features are listed in the ",(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/releases/tag/v3.0.0",children:(0,t.jsx)(s.strong,{children:"Docusaurus v3.0.0 release notes"})}),"."]}),"\n",(0,t.jsx)(s.h3,{id:"markdown",children:"Markdown"}),"\n",(0,t.jsx)(s.p,{children:"Docusaurus v3 upgraded from MDX v1 to MDX v3:"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsxs)(s.li,{children:["in ",(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/8288",children:"#8288"}),", we upgraded to ",(0,t.jsx)(s.a,{href:"https://mdxjs.com/blog/v2/",children:(0,t.jsx)(s.strong,{children:"MDX v2"})})," (",(0,t.jsx)(s.a,{href:"https://mdxjs.com/migrating/v2/",children:"migration guide"}),")"]}),"\n",(0,t.jsxs)(s.li,{children:["in ",(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/9451",children:"#9451"}),", we upgraded to ",(0,t.jsx)(s.a,{href:"https://mdxjs.com/blog/v3/",children:(0,t.jsx)(s.strong,{children:"MDX v3"})})," (",(0,t.jsx)(s.a,{href:"https://mdxjs.com/migrating/v3/",children:"migration guide"}),")"]}),"\n"]}),"\n",(0,t.jsxs)(s.p,{children:["This new MDX version is ",(0,t.jsx)(s.strong,{children:"much better for content writers and plugin authors"}),", and lays the ground for implementing new exciting Markdown features."]}),"\n",(0,t.jsxs)(s.admonition,{title:"MDX v3 - the main challenge",type:"warning",children:[(0,t.jsxs)(s.p,{children:["The transition from MDX v1 to MDX v3 is the ",(0,t.jsx)(s.strong,{children:"main challenge"})," to the adoption of Docusaurus v3."]}),(0,t.jsxs)(s.p,{children:["Some documents that compiled successfully under Docusaurus v2 might now ",(0,t.jsx)(s.strong,{children:"fail to compile"})," under Docusaurus v3, while others might ",(0,t.jsx)(s.strong,{children:"render differently"}),"."]}),(0,t.jsxs)(s.p,{children:["Most breaking changes come from ",(0,t.jsx)(s.a,{href:"https://mdxjs.com/blog/v2/",children:"MDX v2"}),", and ",(0,t.jsx)(s.a,{href:"https://mdxjs.com/blog/v3/",children:"MDX v3"})," is a relatively small release. The ",(0,t.jsx)(s.a,{href:"https://mdxjs.com/migrating/v2/",children:"MDX v2 migration guide"})," has a section on how to ",(0,t.jsx)(s.a,{href:"https://mdxjs.com/migrating/v2/#update-mdx-files",children:"update MDX files"})," that will be particularly relevant to us. Also make sure to read the ",(0,t.jsx)(s.a,{href:"https://mdxjs.com/docs/troubleshooting-mdx/",children:"Troubleshooting MDX"})," page that can help you interpret common MDX error messages."]}),(0,t.jsxs)(s.p,{children:[(0,t.jsx)(s.strong,{children:"Don't be intimidated"}),". Most problems are ",(0,t.jsx)(s.strong,{children:"easy to fix"})," and often related to ",(0,t.jsx)(s.code,{children:"{"})," and ",(0,t.jsx)(s.code,{children:"<"})," characters that you now need to escape. However, depending on the size of your site, you might need to edit many files and feel overwhelmed. For this reason, we provide a command ",(0,t.jsx)(s.a,{href:"https://github.com/slorber/docusaurus-mdx-checker",children:(0,t.jsx)(s.code,{children:"npx docusaurus-mdx-checker"})})," to help you get an estimate of the work to be done, and we recommend to ",(0,t.jsx)(s.a,{href:"/blog/preparing-your-site-for-docusaurus-v3",children:"prepare your site in advance"}),"."]}),(0,t.jsxs)(s.p,{children:["If you created custom ",(0,t.jsx)(s.a,{href:"/docs/markdown-features/plugins",children:"MDX plugins"})," (Remark/Rehype), the AST is slightly different, and you might need to refactor them."]})]}),"\n",(0,t.jsxs)(s.p,{children:["This notably enables us to add a ",(0,t.jsx)(s.a,{href:"/docs/markdown-features#mdx-vs-commonmark",children:"CommonMark mode"})," that should make it easier for existing documentations to adopt Docusaurus. It is currently opt-in and ",(0,t.jsx)(s.strong,{children:"experimental"})," and limited (",(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/issues/9092",children:"some Docusaurus features will not work"}),"). In Docusaurus v3, all files are still interpreted as MDX, but we plan to interpret ",(0,t.jsx)(s.code,{children:".md"})," files as CommonMark in an upcoming major version, and recommend to use the ",(0,t.jsx)(s.code,{children:".mdx"})," extension for any file using JSX or ES modules."]}),"\n",(0,t.jsxs)(s.p,{children:["We also introduced a new way to ",(0,t.jsx)(s.a,{href:"/docs/api/docusaurus-config#markdown",children:"configure Markdown globally for your site"}),", and plan to add more flexible options later."]}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-js",metastring:'title="docusaurus.config.js"',children:"export default {\n markdown: {\n format: 'mdx',\n mermaid: true,\n preprocessor: ({filePath, fileContent}) => {\n return fileContent.replaceAll('{{MY_VAR}}', 'MY_VALUE');\n },\n mdx1Compat: {\n comments: true,\n admonitions: true,\n headingIds: true,\n },\n },\n};\n"})}),"\n",(0,t.jsxs)(s.p,{children:["Docusaurus now uses the ",(0,t.jsx)(s.a,{href:"https://github.com/remarkjs/remark-directive",children:"remark-directive"})," plugin to support admonitions. This also offers you the ability to create your own Remark plugins to extend Markdown with your own ",(0,t.jsx)(s.a,{href:"https://talk.commonmark.org/t/generic-directives-plugins-syntax/444",children:"custom directives"})," such as ",(0,t.jsx)(s.code,{children:":textDirective"}),", ",(0,t.jsx)(s.code,{children:"::leafDirective"})," or ",(0,t.jsx)(s.code,{children:":::containerDirective"}),"."]}),"\n",(0,t.jsx)(s.h3,{id:"esm-ts-configs",children:"ESM and TypeScript configs"}),"\n",(0,t.jsxs)(s.p,{children:["In ",(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/9317",children:"#9317"}),", we added support for ES Modules and TypeScript config files, including site config, docs sidebars, plugins and presets."]}),"\n",(0,t.jsx)(s.p,{children:"Here are 2 TypeScript examples, giving you a modern experience with IDE autocompletion:"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-ts",metastring:'title="docusaurus.config.ts"',children:"import type {Config} from '@docusaurus/types';\nimport type * as Preset from '@docusaurus/preset-classic';\n\nconst config: Config = {\n title: 'My Site',\n favicon: 'img/favicon.ico',\n // your site config ...\n presets: [\n [\n 'classic',\n {\n // your preset config ...\n } satisfies Preset.Options,\n ],\n ],\n themeConfig: {\n // your theme config ...\n } satisfies Preset.ThemeConfig,\n};\n\nexport default config;\n"})}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-ts",metastring:'title="sidebars.ts"',children:"import type {SidebarsConfig} from '@docusaurus/plugin-content-docs';\n\nconst sidebars: SidebarsConfig = {\n docs: ['introduction'],\n};\n\nexport default sidebars;\n"})}),"\n",(0,t.jsx)(s.h3,{id:"unlisted-content",children:"Unlisted content"}),"\n",(0,t.jsxs)(s.p,{children:["Docusaurus already supported a ",(0,t.jsx)(s.code,{children:"draft: true"})," front matter option in our 3 content plugins (docs, blog, pages), which allows you to remove some pages from your production builds."]}),"\n",(0,t.jsxs)(s.p,{children:["In ",(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/8004",children:"#8004"}),", we introduced a new ",(0,t.jsx)(s.code,{children:"unlisted: true"}),' front matter option, which will keep your pages available in production builds, while "hiding" them and making them impossible to discover unless you have the url. This enables convenient workflows where you can easily ask for feedback on a piece of content before the final publication.']}),"\n",(0,t.jsx)(s.p,{children:"Unlisted content will:"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsxs)(s.li,{children:["be excluded from ",(0,t.jsx)(s.code,{children:"sitemap.xml"})]}),"\n",(0,t.jsxs)(s.li,{children:["be excluded from SEO results thanks to ",(0,t.jsx)(s.code,{children:'<meta name="robots" content="noindex, nofollow" />'})]}),"\n",(0,t.jsx)(s.li,{children:"be excluded from blog RSS feeds"}),"\n",(0,t.jsx)(s.li,{children:"be excluded from Algolia DocSearch results"}),"\n",(0,t.jsx)(s.li,{children:"be filtered from site navbar items, docs sidebars, blog sidebar, blog archives, tags pages..."}),"\n"]}),"\n",(0,t.jsxs)(s.p,{children:["Unlisted content will also display a banner so that you don't forget to turn it off once your content is ready for prime time. Here's an example of an ",(0,t.jsx)(s.a,{href:"/tests/blog/unlisted-post",children:"unlisted blog post"}),":"]}),"\n",(0,t.jsx)(a.Z,{url:"/tests/blog/unlisted-post"}),"\n",(0,t.jsx)(s.h3,{id:"react-18",children:"React 18"}),"\n",(0,t.jsxs)(s.p,{children:["In ",(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/8961",children:"#8961"}),", we upgraded to React 18. This is important, notably for the ",(0,t.jsx)(s.a,{href:"https://react.dev/blog/2022/03/29/react-v18#gradually-adopting-concurrent-features",children:"gradual adoption of Concurrent React features"}),", as well as upcoming exciting features such as ",(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/issues/9089",children:"build-time React Server Components"}),"."]}),"\n",(0,t.jsxs)(s.p,{children:["This new version of React should be a drop-in replacement for most Docusaurus sites. It comes with breaking changes that we handled internally in the Docusaurus codebase. If your site is using a lot of custom React code, we recommend you to take a look at the official article on ",(0,t.jsx)(s.a,{href:"https://react.dev/blog/2022/03/08/react-18-upgrade-guide",children:"How to Upgrade to React 18"}),", notably the new ",(0,t.jsx)(s.a,{href:"https://react.dev/blog/2022/03/08/react-18-upgrade-guide#automatic-batching",children:"automatic batching"})," behavior."]}),"\n",(0,t.jsxs)(s.admonition,{title:"Experimental support for React 18 features",type:"danger",children:[(0,t.jsx)(s.p,{children:"React 18 comes with new features:"}),(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.code,{children:"<Suspense>"})}),"\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.code,{children:"React.lazy()"})}),"\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.code,{children:"startTransition()"})}),"\n"]}),(0,t.jsxs)(s.p,{children:["Their Docusaurus support is considered as ",(0,t.jsx)(s.strong,{children:"experimental"}),". We might have to adjust the integration in the future, leading to a different runtime behavior."]})]}),"\n",(0,t.jsx)(s.h3,{id:"automatic-jsx-runtime",children:"Automatic JSX runtime"}),"\n",(0,t.jsxs)(s.p,{children:["Docusaurus now uses the ",(0,t.jsx)(s.a,{href:"https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html",children:'"automatic" JSX runtime'}),"."]}),"\n",(0,t.jsx)(s.p,{children:"It is not needed anymore to import React in JSX files that do not use any React API."}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-diff",metastring:'title="src/components/MyComponent.js"',children:"- import React from 'react';\n\n export default function MyComponent() {\n return <div>Hello</div>;\n }\n"})}),"\n",(0,t.jsx)(s.h3,{id:"debug-builds",children:"Debug builds"}),"\n",(0,t.jsx)(s.p,{children:"It is now possible to build your static site in dev mode."}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-bash",children:"docusaurus build --dev\n"})}),"\n",(0,t.jsxs)(s.admonition,{title:"Debug React-related problems",type:"tip",children:[(0,t.jsxs)(s.p,{children:["Docusaurus will log more errors to the console, notably React 18 hydration errors through the new ",(0,t.jsxs)(s.a,{href:"https://react.dev/reference/react-dom/client/hydrateRoot#parameters",children:[(0,t.jsx)(s.code,{children:"onRecoverableError"})," callback"]}),"."]}),(0,t.jsxs)(s.p,{children:["This new build mode is particularly helpful for ",(0,t.jsx)(s.strong,{children:"troubleshooting React problems"}),". Docusaurus will use the development build of React, thus producing detailed and readable error messages instead of minified ones linking to the ",(0,t.jsx)(s.a,{href:"https://reactjs.org/docs/error-decoder.html/",children:"React Error Decoder page"}),"."]})]}),"\n",(0,t.jsx)(s.h3,{id:"typescript",children:"TypeScript"}),"\n",(0,t.jsx)(s.p,{children:"Docusaurus v3 now requires a minimum version of TypeScript 5.0."}),"\n",(0,t.jsx)(s.p,{children:"We re-internalized the base recommended TypeScript config to a new official package:"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-diff",metastring:'title="tsconfig.json"',children:' {\n- "extends": "@tsconfig/docusaurus/tsconfig.json",\n+ "extends": "@docusaurus/tsconfig",\n "compilerOptions": {\n "baseUrl": "."\n }\n }\n'})}),"\n",(0,t.jsxs)(s.p,{children:["We also have cleaner, normalized exports for Docusaurus core type, plugin, and preset options, which you can use within the brand-new ",(0,t.jsx)(s.a,{href:"#esm-ts-configs",children:"TypeScript config files"}),":"]}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-ts",metastring:'title="docusaurus.config.ts"',children:"import type {Config} from '@docusaurus/types';\nimport type {Options, ThemeConfig} from '@docusaurus/preset-classic';\nimport type {SidebarsConfig} from '@docusaurus/plugin-content-docs';\n"})}),"\n",(0,t.jsx)(s.h3,{id:"code-blocks",children:"Code blocks"}),"\n",(0,t.jsxs)(s.p,{children:["In ",(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/9316",children:"#9316"}),", we improved on syntax highlighting thanks to the ",(0,t.jsx)(s.a,{href:"https://github.com/FormidableLabs/prism-react-renderer",children:"prism-react-renderer"})," v2 upgrade. For example, a bash param ",(0,t.jsx)(s.code,{children:"--save"})," is now colored:"]}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-bash",children:"npm install --save some-package\n"})}),"\n",(0,t.jsxs)(s.p,{children:["The ",(0,t.jsx)(s.a,{href:"/docs/markdown-features/code-blocks#interactive-code-editor",children:"interactive code editor"})," also upgrades to ",(0,t.jsx)(s.a,{href:"https://github.com/FormidableLabs/react-live",children:"react-live"})," v4, coming with a new ",(0,t.jsx)(s.a,{href:"https://github.com/alangpierce/sucrase",children:"sucrase"})," compiler. It is faster, lighter, and supports modern features, notably TypeScript type annotations."]}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-js",metastring:"live",live:!0,children:"function Hello() {\n const name: string = 'World';\n return <div>Hello {name}</div>;\n}\n"})}),"\n",(0,t.jsxs)(s.p,{children:["In ",(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/8982",children:"#8982"})," and ",(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/8870",children:"#8870"}),", we also added ",(0,t.jsx)(s.a,{href:"/docs/markdown-features/code-blocks#custom-magic-comments",children:"magic comments"})," support for TeX-like, Haskell-like, and WebAssembly comment syntax."]}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-haskell",metastring:'title="haskell.hs"',children:"stringLength :: String -> Int\n-- highlight-next-line\nstringLength [] = 0\nstringLength (x:xs) = 1 + stringLength xs\n"})}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-matlab",metastring:'title="matlab.m"',children:"% highlight-start\nfunction result = times2(n)\n result = n * 2;\nend\n% highlight-end\nx = 10;\n% highlight-next-line\ny = times2(x);\n"})}),"\n",(0,t.jsx)(s.h3,{id:"mermaid-diagrams",children:"Mermaid diagrams"}),"\n",(0,t.jsxs)(s.p,{children:["In ",(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/9305",children:"#9305"}),", we upgraded to Mermaid v10.4 and added support for async diagram rendering. Docusaurus is now able to render new types of diagrams."]}),"\n",(0,t.jsxs)(r,{children:[(0,t.jsx)("summary",{children:"Mindmap"}),(0,t.jsx)(s.mermaid,{value:"mindmap\n root((mindmap))\n Research\n Creative techniques\n Strategic planning\n Argument mapping\n Tools\n Pen and paper\n Mermaid"})]}),"\n",(0,t.jsxs)(r,{children:[(0,t.jsx)("summary",{children:"Quadrant chart"}),(0,t.jsx)(s.mermaid,{value:"quadrantChart\n title Reach and engagement of campaigns\n x-axis Low Reach --\x3e High Reach\n y-axis Low Engagement --\x3e High Engagement\n quadrant-1 We should expand\n quadrant-2 Need to promote\n quadrant-3 Re-evaluate\n quadrant-4 May be improved\n Campaign A: [0.3, 0.6]\n Campaign B: [0.45, 0.23]\n Campaign C: [0.57, 0.69]\n Campaign D: [0.78, 0.34]\n Campaign E: [0.40, 0.34]\n Campaign F: [0.35, 0.78]"})]}),"\n",(0,t.jsx)(s.h3,{id:"query-string-data-attributes",children:"Query-string data attributes"}),"\n",(0,t.jsxs)(s.p,{children:["In ",(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/9028",children:"#9028"}),", we made it possible to set custom HTML ",(0,t.jsx)(s.a,{href:"https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/data-*",children:"data attributes"})," though ",(0,t.jsx)(s.code,{children:"docusaurus-data-x"})," query-string parameters. This makes it easier to embed a Docusaurus iframe on another site, and lets you customize the appearance of the embedded version with CSS."]}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-css",metastring:'title="/src/css/custom.css"',children:"html[data-navbar='false'] .navbar {\n display: none;\n}\n\nhtml[data-red-border] div#__docusaurus {\n border: red solid thick;\n}\n"})}),"\n",(0,t.jsx)(a.Z,{url:"/docs/?docusaurus-data-navbar=false&docusaurus-data-red-border"}),"\n",(0,t.jsx)(s.h3,{id:"other-features",children:"Other features"}),"\n",(0,t.jsx)(s.p,{children:"Other new features worth mentioning:"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/9189",children:"#9189"}),": new blog ",(0,t.jsx)(s.code,{children:"feedOptions.limit"})," option"]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/9071",children:"#9071"}),": add normalized SEO front matter support for the pages plugin"]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/9028",children:"#9171"}),": the client-redirects plugin now supports fully qualified urls and query-string/hash in destination url"]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/9171",children:"#9171"}),": new ESLint rule ",(0,t.jsx)(s.a,{href:"/docs/api/misc/@docusaurus/eslint-plugin/no-html-links",children:(0,t.jsx)(s.code,{children:"no-html-links"})})]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/pull/8384",children:"#8384"}),": new ESLint rule ",(0,t.jsx)(s.a,{href:"/docs/api/misc/@docusaurus/eslint-plugin/prefer-docusaurus-heading",children:(0,t.jsx)(s.code,{children:"prefer-docusaurus-heading"})})]}),"\n"]}),"\n",(0,t.jsxs)(s.p,{children:["Read ",(0,t.jsx)(s.a,{href:"https://github.com/facebook/docusaurus/releases/tag/v3.0.0",children:(0,t.jsx)(s.strong,{children:"Docusaurus v3.0.0 release notes"})})," for an exhaustive list of changes."]}),"\n",(0,t.jsx)(s.h2,{id:"conclusion",children:"Conclusion"}),"\n",(0,t.jsxs)(s.p,{children:["This release comes with a few features, but more importantly ",(0,t.jsx)(s.strong,{children:"upgrades many pieces of the Docusaurus infrastructure"}),"."]}),"\n",(0,t.jsxs)(s.p,{children:["The ",(0,t.jsx)(s.strong,{children:"MDX upgrade"})," consumed a lot of our time this year, and we worked hard to make this important upgrade less difficult for all of you."]}),"\n",(0,t.jsxs)(s.p,{children:["Now that we've caught up with our infrastructure, we'll be back ",(0,t.jsx)(s.strong,{children:"delivering useful documentation features"})," very soon, in upcoming minor versions."]}),"\n",(0,t.jsxs)(s.p,{children:["We would like to thank you for using Docusaurus over the years. The documentation framework space is becoming more competitive lately, and we will do our best to ensure that Docusaurus remains a ",(0,t.jsx)(s.strong,{children:"competitive solution"})," that stands out for its great ",(0,t.jsx)(s.strong,{children:"flexibility"}),"."]})]})}function h(e={}){let{wrapper:s}={...(0,i.a)(),...e.components};return s?(0,t.jsx)(s,{...e,children:(0,t.jsx)(u,{...e})}):u(e)}},51118:function(e,s,n){n.d(s,{Z:()=>i});var r=n(85893);n(67294);var t=n(14522);function i(e){let{url:s}=e;return(0,r.jsx)("div",{style:{padding:10},children:(0,r.jsx)(t.Z,{url:s,style:{minWidth:"min(100%,45vw)",width:800,maxWidth:"100%",overflow:"hidden"},bodyStyle:{padding:0},children:(0,r.jsx)("iframe",{src:s,title:s,style:{display:"block",width:"100%",height:300}})})})}},14522:function(e,s,n){n.d(s,{Z:()=>o});var r=n(85893);n(67294);var t=n(90496);let i="dot_giz1",a="bar_rrRL";function o(e){let{children:s,minHeight:n,url:o="http://localhost:3000",style:c,bodyStyle:l}=e;return(0,r.jsxs)("div",{className:"browserWindow_my1Q",style:{...c,minHeight:n},children:[(0,r.jsxs)("div",{className:"browserWindowHeader_jXSR",children:[(0,r.jsxs)("div",{className:"buttons_uHc7",children:[(0,r.jsx)("span",{className:i,style:{background:"#f25f58"}}),(0,r.jsx)("span",{className:i,style:{background:"#fbbe3c"}}),(0,r.jsx)("span",{className:i,style:{background:"#58cb42"}})]}),(0,r.jsx)("div",{className:(0,t.Z)("browserWindowAddressBar_Pd8y","text--truncate"),children:o}),(0,r.jsx)("div",{className:"browserWindowMenuIcon_Vhuh",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:a}),(0,r.jsx)("span",{className:a}),(0,r.jsx)("span",{className:a})]})})]}),(0,r.jsx)("div",{className:"browserWindowBody_Idgs",style:l,children:s})]})}},80980:function(e,s,n){n.d(s,{Z:()=>o,a:()=>a});var r=n(67294);let t={},i=r.createContext(t);function a(e){let s=r.useContext(i);return r.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function o(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:a(e.components),r.createElement(i.Provider,{value:s},e.children)}},80931:function(e){e.exports=JSON.parse('{"permalink":"/blog/releases/3.0","editUrl":"https://github.com/facebook/docusaurus/edit/main/website/blog/releases/3.0/index.mdx","source":"@site/blog/releases/3.0/index.mdx","title":"Announcing Docusaurus 3.0","description":"Today, we are happy to announce Docusaurus 3.0! \uD83E\uDD73","date":"2023-10-31T00:00:00.000Z","tags":[{"inline":false,"label":"Release","permalink":"/blog/tags/release","description":"Blog posts about Docusaurus\' new releases"}],"readingTime":10.515,"hasTruncateMarker":true,"authors":[{"name":"S\xe9bastien Lorber","title":"Docusaurus maintainer, This Week In React editor","url":"https://thisweekinreact.com","page":{"permalink":"/blog/authors/slorber"},"description":"A freelance React and React-Native developer near Paris and Docusaurus maintainer. Also runs ThisWeekInReact.com, a newsletter to stay updated with the React ecosystem.","socials":{"bluesky":"https://bsky.app/profile/sebastienlorber.com","x":"https://x.com/sebastienlorber","linkedin":"https://www.linkedin.com/in/sebastienlorber/","github":"https://github.com/slorber","instagram":"https://www.instagram.com/thisweekinreact","newsletter":"https://thisweekinreact.com"},"imageURL":"https://github.com/slorber.png","key":"slorber"}],"frontMatter":{"title":"Announcing Docusaurus 3.0","authors":["slorber"],"tags":["release"],"image":"./img/social-card.png","date":"2023-10-31T00:00:00.000Z"},"unlisted":false,"lastUpdatedAt":1742826697000,"lastUpdatedBy":"S\xe9bastien Lorber","prevItem":{"title":"Docusaurus 3.1","permalink":"/blog/releases/3.1"},"nextItem":{"title":"Preparing your site for Docusaurus v3","permalink":"/blog/preparing-your-site-for-docusaurus-v3"}}')}}]);