Aller au contenu principal

Docusaurus 2.3

· 4 minutes de lecture
Sébastien Lorber

Nous sommes heureux d'annoncer Docusaurus 2.3.

La mise à jour devrait être facile : comme expliqué dans notre documentation sur le processus de version, les versions mineures respectent le versionnement sémantique.

Carte sociale Docusaurus 2.2

Points importants

Google Tag Manager plugin

Google Tag Manager is a tag management system that allows great flexibility. It enables analytics and marketing teams to easily load other third-party trackers and fire analytics tags.

We now have a @docusaurus/plugin-google-tag-manager package that you can use alongside or as an alternative to the existing gtag.js plugin (refer to this doc to understand when to use which solution).

Google is sunsetting Universal Analytics

Google will sunset its Universal Analytics on July 1, 2023, and ask users to migrate to Google Analytics 4.

Therefore, we are also deprecating our existing @docusaurus/plugin-google-analytics package. Docusaurus users should create a new Google Analytics 4 property, and migrate to the gtag.js plugin, or the Google Tag Manager plugin. Refer to the dedicated Docusaurus issue for details and questions.

Tabs Query String Support

It is now possible to link a selected tab to a query string parameter. When a tab is selected, it will be stored in your browser URL as a ?qs-param=tab-value search parameter.

This feature allows deep-linking to a specific documentation tab that will pre-selected on page load.

When used alongside the groupId prop, the query string tab value takes precedence over the localStorage value.

Make sure to check the documentation and the demo below to understand how it works:

<Tabs groupId="current-os" queryString>
<TabItem value="android" label="Android">
Android
</TabItem>
<TabItem value="ios" label="iOS">
iOS
</TabItem>
</Tabs>
http://localhost:3000
Android

Admonitions imbriquées

It is now possible to nest one admonition within another by adding extra colons for the outer/enclosing admonition:

::::tip nested admonitions

You can now nest one admonition within another!

:::danger

Use this sparingly when it makes sense.

:::

:
:::
nested admonitions

You can now nest one admonition within another!

danger

Use this sparingly when it makes sense.

: :::

Blog createFeedItems

A new blog plugin option feedOptions.createFeedItems gives you more control over the RSS/Atom feed generation. It is now possible to transform/filter/limit feed items through a new callback.

docusaurus.config.js
[
'@docusaurus/preset-classic',
{
blog: {
feedOptions: {
createFeedItems: async (params) => {
const {blogPosts, defaultCreateFeedItems, ...rest} = params;
return defaultCreateFeedItems({
// keep only the 10 most recent blog posts in the feed
blogPosts: blogPosts.filter((item, index) => index < 10),
...rest,
});
},
},
},
},
];

Traductions

Nous avons ajouté ou terminé la prise en charge par défaut de la traduction du thème pour plusieurs langues :

astuce

Compléter les traductions de thèmes est un effort constant et un moyen facile de contribuer à Docusaurus. Nous ajoutons régulièrement de nouvelles fonctionnalités de thème, pour lesquelles nous avons souvent besoin de nouvelles traductions.

Autres modifications

Les autres changements notables sont les suivants :

  • #8463 and #8328: fix some annoying Docusaurus layout issues
  • #8539: Algolia plugin options.searchPagePath should be correctly applied to search modal footer
  • #8462: Algolia plugin now makes it easier to transform displayed search results with custom logic
  • #8397: the deploy CLI now understands git url insteadOf config

Check the 2.3.0 changelog entry for an exhaustive list of changes.