mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-25 17:22:50 +00:00
fix(theme-classic): expose empty string alt text in navbar logos (#7659)
* fix: Expose empty string alt text in brand logos via nullish coalescing * fix: Update boolean logic for fallbacks * fix: Dogfood fix on Docusaurus brand logo * refactor: Un-inline alt logic, and reduce chance of duplication in fallback
This commit is contained in:
parent
fd87afd249
commit
3990404419
|
|
@ -27,12 +27,21 @@ export default function Logo(props: Props): JSX.Element {
|
|||
light: useBaseUrl(logo.src),
|
||||
dark: useBaseUrl(logo.srcDark || logo.src),
|
||||
};
|
||||
|
||||
// If visible title is shown, fallback alt text should be
|
||||
// an empty string to mark the logo as decorative.
|
||||
const fallbackAlt = navbarTitle ? '' : title;
|
||||
|
||||
// Use logo alt text if provided (including empty string),
|
||||
// and provide a sensible fallback otherwise.
|
||||
const alt = logo.alt ?? fallbackAlt;
|
||||
|
||||
const themedImage = (
|
||||
<ThemedImage
|
||||
sources={sources}
|
||||
height={logo.height}
|
||||
width={logo.width}
|
||||
alt={logo.alt || navbarTitle || title}
|
||||
alt={alt}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ const config = {
|
|||
hideOnScroll: true,
|
||||
title: 'Docusaurus',
|
||||
logo: {
|
||||
alt: 'Docusaurus Logo',
|
||||
alt: '',
|
||||
src: 'img/docusaurus.svg',
|
||||
srcDark: 'img/docusaurus_keytar.svg',
|
||||
width: 32,
|
||||
|
|
|
|||
Loading…
Reference in New Issue