chore: backport retro compatible commits for the Docusaurus v2.4 release (#8809)

Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
Co-authored-by: Ben Gubler <nebrelbug@gmail.com>
Co-authored-by: Davide Donadio <davide.donadio@it.clara.net>
Co-authored-by: Petter Drønnen <36735557+dr0nn1@users.noreply.github.com>
Co-authored-by: Moritz Stückler <moritz@bitbetter.de>
Co-authored-by: Mysterious_Dev <40738104+Mysterious-Dev@users.noreply.github.com>
Co-authored-by: TrueQAP <32407751+trueqap@users.noreply.github.com>
Co-authored-by: Kagan <34136752+kagankan@users.noreply.github.com>
Co-authored-by: Dewansh Thakur <71703033+dewanshDT@users.noreply.github.com>
Co-authored-by: Armano <armano2@users.noreply.github.com>
Co-authored-by: Anas <60762285+Anasqx@users.noreply.github.com>
Co-authored-by: Tanner Dolby <tannercdolby@gmail.com>
Co-authored-by: Davide Donadio <davide.donadio94@gmail.com>
Co-authored-by: biplavmz <68702055+biplavmz@users.noreply.github.com>
Co-authored-by: Vishruta Patil <72292532+Vishruta-Patil@users.noreply.github.com>
fix(theme-classic): fix tab focus bug in dropdown (#8697) (#8699)
fix(theme): improve color toggle when using dark navbar (#8615)
fix(theme-translations): fix wrong arabic words (tip/next) (#8744)
fix(core): baseUrl error banner link anchor case (#8746)
fix(search): search page should react to querystring changes + cleanup/refactor (#8757)
fix(theme): allow tabs children to be falsy (#8801)
fix(theme): codeblock buttons should be kept on the right when using RTL locale (#8803)
This commit is contained in:
Sébastien Lorber 2023-03-24 09:23:58 +01:00 committed by GitHub
parent 985a64ad22
commit 4fb67ef11b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
122 changed files with 1732 additions and 494 deletions

View file

@ -16,6 +16,9 @@ const {
dogfoodingThemeInstances,
} = require('./_dogfooding/dogfooding.config');
/** @type {Record<string,Record<string,string>>} */
const ConfigLocalized = require('./docusaurus.config.localized.json');
const ArchivedVersionsDropdownItems = Object.entries(VersionsArchived).splice(
0,
5,
@ -23,16 +26,7 @@ const ArchivedVersionsDropdownItems = Object.entries(VersionsArchived).splice(
// This probably only makes sense for the alpha/beta/rc phase, temporary
function getNextVersionName() {
const expectedPrefix = '2.0.0-rc.';
const lastReleasedVersion = versions[0];
if (!lastReleasedVersion || !lastReleasedVersion.includes(expectedPrefix)) {
throw new Error(
'this code is only meant to be used during the 2.0 alpha/beta/rc phase.',
);
}
const version = parseInt(lastReleasedVersion.replace(expectedPrefix, ''), 10);
return `${expectedPrefix}${version + 1}`;
return 'Canary';
}
const isDev = process.env.NODE_ENV === 'development';
@ -59,10 +53,27 @@ const isVersioningDisabled = !!process.env.DISABLE_VERSIONING || isI18nStaging;
const TwitterSvg =
'<svg style="fill: #1DA1F2; vertical-align: middle; margin-left: 3px;" width="16" height="16" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"></path></svg>';
const defaultLocale = 'en';
function getLocalizedConfigValue(/** @type {string} */ key) {
const currentLocale = process.env.DOCUSAURUS_CURRENT_LOCALE ?? defaultLocale;
const values = ConfigLocalized[key];
if (!values) {
throw new Error(`Localized config key=${key} not found`);
}
const value = values[currentLocale] ?? values[defaultLocale];
if (!value) {
throw new Error(
`Localized value for config key=${key} not found for both currentLocale=${currentLocale} or defaultLocale=${defaultLocale}`,
);
}
return value;
}
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Docusaurus',
tagline: 'Build optimized websites quickly, focus on your content',
tagline: getLocalizedConfigValue('tagline'),
organizationName: 'facebook',
projectName: 'docusaurus',
baseUrl,
@ -79,17 +90,16 @@ const config = {
},
],
i18n: {
defaultLocale: 'en',
defaultLocale,
locales:
isDeployPreview || isBranchDeploy
? // Deploy preview and branch deploys: keep them fast!
['en']
[defaultLocale]
: isI18nStaging
? // Staging locales: https://docusaurus-i18n-staging.netlify.app/
['en', 'ja']
[defaultLocale, 'ja']
: // Production locales
['en', 'fr', 'pt-BR', 'ko', 'zh-CN'],
[defaultLocale, 'fr', 'pt-BR', 'ko', 'zh-CN'],
},
webpack: {
jsLoader: (isServer) => ({
@ -147,7 +157,7 @@ const config = {
description:
'Keep yourself up-to-date about new features in every release',
copyright: `Copyright © ${new Date().getFullYear()} Facebook, Inc.`,
language: 'en',
language: defaultLocale,
},
},
],
@ -159,7 +169,7 @@ const config = {
path: 'community',
routeBasePath: 'community',
editUrl: ({locale, versionDocsDirPath, docPath}) => {
if (locale !== 'en') {
if (locale !== defaultLocale) {
return `https://crowdin.com/project/docusaurus-v2/${locale}`;
}
return `https://github.com/facebook/docusaurus/edit/main/website/${versionDocsDirPath}/${docPath}`;
@ -288,7 +298,7 @@ const config = {
// sidebarCollapsible: false,
// sidebarCollapsed: true,
editUrl: ({locale, docPath}) => {
if (locale !== 'en') {
if (locale !== defaultLocale) {
return `https://crowdin.com/project/docusaurus-v2/${locale}`;
}
// We want users to submit doc updates to the upstream/next version!
@ -324,7 +334,7 @@ const config = {
// routeBasePath: '/',
path: 'blog',
editUrl: ({locale, blogDirPath, blogPath}) => {
if (locale !== 'en') {
if (locale !== defaultLocale) {
return `https://crowdin.com/project/docusaurus-v2/${locale}`;
}
return `https://github.com/facebook/docusaurus/edit/main/website/${blogDirPath}/${blogPath}`;
@ -349,7 +359,7 @@ const config = {
},
gtag: !(isDeployPreview || isBranchDeploy)
? {
trackingID: 'UA-141789564-1',
trackingID: ['G-E5CR2Q1NRE', 'UA-141789564-1'],
}
: undefined,
sitemap: {