Skip to content

Commit

Permalink
refactor: Un-inline alt logic, and reduce chance of duplication in fa…
Browse files Browse the repository at this point in the history
…llback
  • Loading branch information
BenDMyers committed Jun 22, 2022
1 parent 03cc4ae commit 29df18e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/docusaurus-theme-classic/src/theme/Logo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
/>
);

Expand Down

0 comments on commit 29df18e

Please sign in to comment.