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 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"], 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", 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 ( ); 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}