website/blog/releases/2.4/index.mdx
We are happy to announce Docusaurus 2.4.
The upgrade should be easy: as explained in our release process documentation, minor versions respect Semantic Versioning.
import BrowserWindow from '@site/src/components/BrowserWindow'; import IframeWindow from '@site/src/components/BrowserWindow/IframeWindow'; import ErrorBoundaryTestButton from '@site/src/components/ErrorBoundaryTestButton';
In #8236, we made it possible to provide a new description attribute for docs sidebar items of type link and category.
[
{
type: 'link',
label: 'Link with description',
href: 'https://docusaurus.io',
// highlight-next-line
description: 'Some link description',
},
{
type: 'category',
label: 'Category with description',
// highlight-next-line
description: 'Some category description',
items: [],
},
];
These descriptions will be used in category generated index pages.
In #8708, we added the possibility to force Docusaurus to initialize itself in light or dark mode through a new docusaurus-theme query-string parameter.
This is useful to ensure a consistent theme when embedding an existing Docusaurus page into an iframe or WebView.
<IframeWindow url="/docs/?docusaurus-theme=light" /> <IframeWindow url="/docs/?docusaurus-theme=dark" />In #8690, we upgraded our Remark plugin @docusaurus/remark-plugin-npm2yarn with many conversion bug fixes, first-class support for pnpm, and the ability to register custom converters producing new tabs.
Run these commands!
```bash npm2yarn
npm install
npm run build
npm run myCustomScript -- --some-arg
```
npm install
npm run build
npm run myCustomScript -- --some-arg
In #8620 we added support for the @docusaurus/plugin-google-gtag plugin to declare multiple tracking IDs.
module.exports = {
presets: [
[
'@docusaurus/preset-classic',
{
gtag: {
trackingID: [
// highlight-next-line
'G-<YOUR-NEW-GA4-ID>',
// highlight-next-line
'UA-<YOUR-OLD-UA-ID>',
],
},
},
],
],
};
:::warning Google is sunsetting Universal Analytics
Google will sunset its Universal Analytics on July 1, 2023.
Docusaurus users should migrate to Google Analytics 4. Google does not permit to migrate your existing Universal Analytics data to your new Google Analytics 4 property.
To preserve the continuity of your analytics, we temporarily recommend that you report events to 2 tracking IDs at the same time: the old one (UA-*) and new one (G-*). Refer to the dedicated issue for details.
:::
In #8736, we improved how we render error messages and added initial support to render the full causal chain of an error (see ES2022 Error Cause).
:::tip
To see it in action, click here: <ErrorBoundaryTestButton cause="Probably undefined is not a function 😄"/>
:::
In #8735 we also made navbar-related error messages clearer to help users understand what they did wrong.
We made it possible to translate some new elements:
process.env.DOCUSAURUS_CURRENT_LOCALE (experimental) allowing you to localize your config file, including site title, tagline, announcement bar, baseUrl...We added default theme translation support for multiple languages:
:::tip
Completing theme translations is an ongoing effort and an easy way to contribute to Docusaurus. We add new theme features regularly, for which we often need new translations.
:::
Other notable changes include:
prefers-reduced-motion: reduce media querydocSidebar in templateCheck the 2.4.0 changelog entry for an exhaustive list of changes.