diff --git a/packages/docusaurus-theme-classic/src/__tests__/__snapshots__/translations.test.ts.snap b/packages/docusaurus-theme-classic/src/__tests__/__snapshots__/translations.test.ts.snap index d36f4e69596b..b16d98d5a498 100644 --- a/packages/docusaurus-theme-classic/src/__tests__/__snapshots__/translations.test.ts.snap +++ b/packages/docusaurus-theme-classic/src/__tests__/__snapshots__/translations.test.ts.snap @@ -16,6 +16,10 @@ exports[`getTranslationFiles returns translation files matching snapshot 1`] = ` "description": "Navbar item with label Dropdown item 2", "message": "Dropdown item 2", }, + "logo.alt": { + "description": "The alt of navbar logo", + "message": "Navbar alt Logo", + }, "title": { "description": "The title in the navbar", "message": "navbar title", @@ -49,6 +53,10 @@ exports[`getTranslationFiles returns translation files matching snapshot 1`] = ` "description": "The title of the footer links column with title=Footer link column 2 in the footer", "message": "Footer link column 2", }, + "logo.alt": { + "description": "The alt of footer logo", + "message": "Footer alt Logo", + }, }, "path": "footer", }, @@ -71,6 +79,10 @@ exports[`getTranslationFiles returns translation files matching snapshot 2`] = ` "description": "Navbar item with label Dropdown item 2", "message": "Dropdown item 2", }, + "logo.alt": { + "description": "The alt of navbar logo", + "message": "Navbar alt Logo", + }, "title": { "description": "The title in the navbar", "message": "navbar title", @@ -92,6 +104,10 @@ exports[`getTranslationFiles returns translation files matching snapshot 2`] = ` "description": "The label of footer link with label=Link 2 linking to https://facebook.com", "message": "Link 2", }, + "logo.alt": { + "description": "The alt of footer logo", + "message": "Footer alt Logo", + }, }, "path": "footer", }, @@ -131,6 +147,10 @@ exports[`translateThemeConfig returns translated themeConfig 1`] = ` "title": "Footer link column 2 (translated)", }, ], + "logo": { + "alt": "Footer alt Logo", + "src": "/img/test_logo.svg", + }, "style": "light", }, "navbar": { @@ -150,6 +170,10 @@ exports[`translateThemeConfig returns translated themeConfig 1`] = ` "label": "Dropdown (translated)", }, ], + "logo": { + "alt": "Navbar alt Logo", + "src": "/img/test_logo.svg", + }, "style": "dark", "title": "navbar title (translated)", }, diff --git a/packages/docusaurus-theme-classic/src/__tests__/translations.test.ts b/packages/docusaurus-theme-classic/src/__tests__/translations.test.ts index ba4d3464ea35..2abcfa961f77 100644 --- a/packages/docusaurus-theme-classic/src/__tests__/translations.test.ts +++ b/packages/docusaurus-theme-classic/src/__tests__/translations.test.ts @@ -18,6 +18,10 @@ const ThemeConfigSample = { }, navbar: { title: 'navbar title', + logo: { + alt: 'Navbar alt Logo', + src: '/img/test_logo.svg', + }, style: 'dark', hideOnScroll: false, items: [ @@ -31,6 +35,10 @@ const ThemeConfigSample = { ], }, footer: { + logo: { + alt: 'Footer alt Logo', + src: '/img/test_logo.svg', + }, copyright: 'Copyright FB', style: 'light', links: [ @@ -52,6 +60,10 @@ const ThemeConfigSample = { const ThemeConfigSampleSimpleFooter: ThemeConfig = { ...ThemeConfigSample, footer: { + logo: { + alt: 'Footer alt Logo', + src: '/img/test_logo.svg', + }, copyright: 'Copyright FB', style: 'light', links: [ diff --git a/packages/docusaurus-theme-classic/src/translations.ts b/packages/docusaurus-theme-classic/src/translations.ts index cc087a87d85a..2e9fb5cb3570 100644 --- a/packages/docusaurus-theme-classic/src/translations.ts +++ b/packages/docusaurus-theme-classic/src/translations.ts @@ -45,7 +45,20 @@ function getNavbarTranslationFile(navbar: Navbar): TranslationFileContent { ? {title: {message: navbar.title, description: 'The title in the navbar'}} : {}; - return mergeTranslations([titleTranslations, navbarItemsTranslations]); + const logoAlt: TranslationFileContent = navbar.logo?.alt + ? { + 'logo.alt': { + message: navbar.logo?.alt, + description: 'The alt of navbar logo', + }, + } + : {}; + + return mergeTranslations([ + titleTranslations, + logoAlt, + navbarItemsTranslations, + ]); } function translateNavbar( navbar: Navbar, @@ -119,7 +132,21 @@ function getFooterTranslationFile(footer: Footer): TranslationFileContent { } : {}; - return mergeTranslations([footerLinkTitles, footerLinkLabels, copyright]); + const logoAlt: TranslationFileContent = footer.logo?.alt + ? { + 'logo.alt': { + message: footer.logo?.alt, + description: 'The alt of footer logo', + }, + } + : {}; + + return mergeTranslations([ + footerLinkTitles, + footerLinkLabels, + copyright, + logoAlt, + ]); } function translateFooter( footer: Footer,