From 4860b0eb9a06e60fc40ba73b5ee4d413f32ae070 Mon Sep 17 00:00:00 2001 From: Nolann Biron Date: Fri, 10 Oct 2025 00:27:21 +0200 Subject: [PATCH 1/6] Add alt text support to card covers --- .../DocumentView/Table/RecordCard.tsx | 2 ++ .../components/DocumentView/Table/utils.ts | 19 +++++++++++-------- .../gitbook/src/components/utils/Image.tsx | 19 +++++++++++++------ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/packages/gitbook/src/components/DocumentView/Table/RecordCard.tsx b/packages/gitbook/src/components/DocumentView/Table/RecordCard.tsx index 68ddb254df..8d34e5210f 100644 --- a/packages/gitbook/src/components/DocumentView/Table/RecordCard.tsx +++ b/packages/gitbook/src/components/DocumentView/Table/RecordCard.tsx @@ -85,11 +85,13 @@ export async function RecordCard( light: { src: lightCover.href, size: lightCover.file?.dimensions, + alt: light.alt, }, dark: darkCover ? { src: darkCover.href, size: darkCover.file?.dimensions, + alt: dark.alt, } : null, }} diff --git a/packages/gitbook/src/components/DocumentView/Table/utils.ts b/packages/gitbook/src/components/DocumentView/Table/utils.ts index 540df2dc40..8ada675ece 100644 --- a/packages/gitbook/src/components/DocumentView/Table/utils.ts +++ b/packages/gitbook/src/components/DocumentView/Table/utils.ts @@ -21,6 +21,12 @@ export function getRecordValue ) { - const { sources, style, inline = false, ...rest } = props; + const { sources, style, inline = false, alt, ...rest } = props; return ( <> @@ -119,6 +124,7 @@ export function Image( sources.dark ? 'dark:hidden' : null, style )} + alt={sources.light.alt ?? alt} /> {sources.dark ? ( ) : null} From 5a0622456e8f220ba03e55583e3a5c2d1e1b9214 Mon Sep 17 00:00:00 2001 From: Nolann Biron Date: Fri, 10 Oct 2025 00:50:03 +0200 Subject: [PATCH 2/6] changeset --- .changeset/proud-kings-know.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/proud-kings-know.md diff --git a/.changeset/proud-kings-know.md b/.changeset/proud-kings-know.md new file mode 100644 index 0000000000..77cefd0dfe --- /dev/null +++ b/.changeset/proud-kings-know.md @@ -0,0 +1,6 @@ +--- +'@gitbook/react-openapi': patch +'gitbook': patch +--- + +Add alt text support to card covers From 440ad4b8be6ce68b8e49d0e9bd0e4d5881b2e21f Mon Sep 17 00:00:00 2001 From: Nolann Biron Date: Sat, 11 Oct 2025 12:09:57 +0200 Subject: [PATCH 3/6] default alt --- packages/gitbook/src/components/utils/Image.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/gitbook/src/components/utils/Image.tsx b/packages/gitbook/src/components/utils/Image.tsx index 829364e3d1..2675336cfa 100644 --- a/packages/gitbook/src/components/utils/Image.tsx +++ b/packages/gitbook/src/components/utils/Image.tsx @@ -124,7 +124,7 @@ export function Image( sources.dark ? 'dark:hidden' : null, style )} - alt={sources.light.alt ?? alt} + alt={sources.light.alt || alt} /> {sources.dark ? ( ) : null} From 2f5423268665e6340d593a128989030e0d3c370f Mon Sep 17 00:00:00 2001 From: Nolann Biron Date: Thu, 23 Oct 2025 17:17:31 +0200 Subject: [PATCH 4/6] Update API --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 721d953e18..207f891db9 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "catalog": { "@tsconfig/strictest": "^2.0.6", "@tsconfig/node20": "^20.1.6", - "@gitbook/api": "0.145.0", + "@gitbook/api": "0.146.0", "@scalar/api-client-react": "^1.3.46", "@types/react": "^19.0.0", "@types/react-dom": "^19.0.0", From 1cddd746e1d4be83dc5fae90035f2d2757374bfc Mon Sep 17 00:00:00 2001 From: Nolann Biron Date: Thu, 23 Oct 2025 17:22:33 +0200 Subject: [PATCH 5/6] Fix @ts-expect-error unnecessary --- .../gitbook/src/components/DocumentView/InlineIcon.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/gitbook/src/components/DocumentView/InlineIcon.tsx b/packages/gitbook/src/components/DocumentView/InlineIcon.tsx index e0d92e3a0e..18ff08dff7 100644 --- a/packages/gitbook/src/components/DocumentView/InlineIcon.tsx +++ b/packages/gitbook/src/components/DocumentView/InlineIcon.tsx @@ -1,4 +1,4 @@ -import type { DocumentInlineIcon, DocumentMarkColor } from '@gitbook/api'; +import type { DocumentInlineIcon } from '@gitbook/api'; import { tcls } from '@/lib/tailwind'; import { Icon, type IconName } from '@gitbook/icons'; @@ -7,14 +7,11 @@ import { textColorToStyle } from './utils/colors'; export async function InlineIcon(props: InlineProps) { const { inline } = props; - const icon = inline.data.icon as IconName; - const color = inline.data.color - ? (inline.data.color as DocumentMarkColor['data']['text']) - : undefined; + const { color, icon } = inline.data; return ( ); From 764b56451df390cc2c3ac119a5f5b349c5f5342a Mon Sep 17 00:00:00 2001 From: Nolann Biron Date: Fri, 24 Oct 2025 15:11:10 +0200 Subject: [PATCH 6/6] update lock --- bun.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bun.lock b/bun.lock index 008f621c87..f981ccf8d7 100644 --- a/bun.lock +++ b/bun.lock @@ -343,7 +343,7 @@ "react-dom": "catalog:", }, "catalog": { - "@gitbook/api": "0.145.0", + "@gitbook/api": "0.146.0", "@scalar/api-client-react": "^1.3.46", "@tsconfig/node20": "^20.1.6", "@tsconfig/strictest": "^2.0.6", @@ -724,7 +724,7 @@ "@fortawesome/fontawesome-svg-core": ["@fortawesome/fontawesome-svg-core@6.6.0", "", { "dependencies": { "@fortawesome/fontawesome-common-types": "6.6.0" } }, "sha512-KHwPkCk6oRT4HADE7smhfsKudt9N/9lm6EJ5BVg0tD1yPA5hht837fB87F8pn15D8JfTqQOjhKTktwmLMiD7Kg=="], - "@gitbook/api": ["@gitbook/api@0.145.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-pq+lqUPdvrVstpojs7uOimaNePg16uE1X2Dx7VDulqResmNp/FiV8a1i99vlYHhfhVA/U7i6wAN0iX4zi0/YZA=="], + "@gitbook/api": ["@gitbook/api@0.146.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-gWcSCbN+9Zc/XOEk4t8v70kKyaVJQytHMnnstArr8av1YpHzZWEpVQCeQ20SnJvkvO5y+P7TCVxJCLG2ciT9SQ=="], "@gitbook/browser-types": ["@gitbook/browser-types@workspace:packages/browser-types"],