Skip to content

Commit eab69da

Browse files
committed
Support alt-text for navbar logo
Fixes #711
1 parent ae870c2 commit eab69da

File tree

9 files changed

+36
-7
lines changed

9 files changed

+36
-7
lines changed

news/changelog-1.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
## Websites
3939

4040
- Correctly align dark/light toggle in navbar (thanks @FabioRosado)
41+
- Support `navbar:logo-alt` to provide alternate text for navbar logos
4142

4243
## Books
4344

src/project/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,14 @@ export type LayoutBreak = "" | "sm" | "md" | "lg" | "xl" | "xxl";
104104
export const kAriaLabel = "aria-label";
105105
export const kCollapseLevel = "collapse-level";
106106
export const kCollapseBelow = "collapse-below";
107+
export const kLogoAlt = "logo-alt";
107108

108109
export const kSidebarMenus = "sidebar-menus";
109110

110111
export interface Navbar {
111112
title?: string | false;
112113
logo?: string;
114+
[kLogoAlt]?: string;
113115
background:
114116
| "primary"
115117
| "secondary"

src/project/types/website/website-navigation.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ import {
4747

4848
import { kDataQuartoSourceUrl } from "../../../command/render/codetools.ts";
4949

50-
import { kProjectType, ProjectConfig, ProjectContext } from "../../types.ts";
50+
import {
51+
kLogoAlt,
52+
kProjectType,
53+
ProjectConfig,
54+
ProjectContext,
55+
} from "../../types.ts";
5156
import { projectOffset, projectOutputDir } from "../../project-shared.ts";
5257
import { resolveInputTarget } from "../../project-index.ts";
5358
import {
@@ -947,6 +952,7 @@ async function navbarEjsData(
947952
: false,
948953
background: navbar.background || "primary",
949954
logo: resolveLogo(navbar.logo),
955+
[kLogoAlt]: navbar[kLogoAlt],
950956
collapse,
951957
[kCollapseBelow]: !collapse
952958
? ""

src/resources/editor/tools/vs-code.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9106,6 +9106,11 @@ var require_yaml_intelligence_resources = __commonJS({
91069106
description: "Path to a logo image that will be displayed to the left of the title."
91079107
}
91089108
},
9109+
"logo-alt": {
9110+
string: {
9111+
description: "Alternate text for the logo image."
9112+
}
9113+
},
91099114
background: {
91109115
anyOf: [
91119116
{

src/resources/editor/tools/yaml/web-worker.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/resources/editor/tools/yaml/yaml-intelligence-resources.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,6 +2085,11 @@
20852085
"description": "Path to a logo image that will be displayed to the left of the title."
20862086
}
20872087
},
2088+
"logo-alt": {
2089+
"string": {
2090+
"description": "Alternate text for the logo image."
2091+
}
2092+
},
20882093
"background": {
20892094
"anyOf": [
20902095
{

src/resources/projects/website/templates/nav-before-body.ejs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
<% if (nav.navbar) { %>
1111
<nav class="navbar navbar-expand<%- nav.navbar["collapse-below"] %> navbar-dark <%- nav.navbar.background === "none" || nav.navbar.background === "body" ? "border-bottom" : "" %>">
1212
<div class="navbar-container container-fluid">
13-
<% partial('navbrand.ejs', nav.navbar) %>
13+
<% partial('navbrand.ejs', {
14+
navbar: nav.navbar
15+
}) %>
1416
<% if (nav.navbar.left || nav.navbar.right) { %>
1517
<% if (nav.navbar.collapse) { %>
1618
<% partial('navtoggle.ejs') %>
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<% if (title || logo) { %>
1+
<% if (navbar.title || navbar.logo) { %>
22
<a class="navbar-brand" href="/index.html">
3-
<% if (logo) { %>
4-
<img src="<%- logo %>" alt="" />
3+
<% if (navbar.logo) { %>
4+
<img src="<%- navbar.logo %>" alt="<%- navbar['logo-alt'] || '' %>" />
55
<% } %>
6-
<% if (title) { %>
7-
<span class="navbar-title"><%- title %></span>
6+
<% if (navbar.title) { %>
7+
<span class="navbar-title"><%- navbar.title %></span>
88
<% } %>
99
</a>
1010
<% } %>

src/resources/schema/definitions.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,9 @@
656656
logo:
657657
path:
658658
description: "Path to a logo image that will be displayed to the left of the title."
659+
logo-alt:
660+
string:
661+
description: "Alternate text for the logo image."
659662
background:
660663
anyOf:
661664
- enum:

0 commit comments

Comments
 (0)