From e524e4053a85a076b922700766ec75f02f34fec4 Mon Sep 17 00:00:00 2001 From: Duknam Yoo Date: Fri, 29 Nov 2024 09:59:25 +0900 Subject: [PATCH] feat: add alt text support for images --- packages/notion-types/src/block.ts | 1 + packages/react-notion-x/src/components/asset.tsx | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/notion-types/src/block.ts b/packages/notion-types/src/block.ts index 48140b8cd..ff6996772 100644 --- a/packages/notion-types/src/block.ts +++ b/packages/notion-types/src/block.ts @@ -131,6 +131,7 @@ export interface BaseContentBlock extends BaseBlock { properties: { source: string[][] caption?: Decoration[] + alt_text?: Decoration[] } format?: { block_alignment: 'center' | 'left' | 'right' diff --git a/packages/react-notion-x/src/components/asset.tsx b/packages/react-notion-x/src/components/asset.tsx index 17acf812e..30e163893 100644 --- a/packages/react-notion-x/src/components/asset.tsx +++ b/packages/react-notion-x/src/components/asset.tsx @@ -280,8 +280,9 @@ export function Asset({ source = block.properties?.source?.[0]?.[0] } const src = mapImageUrl(source, block as Block) + const altText = getTextContent(block.properties?.alt_text) const caption = getTextContent(block.properties?.caption) - const alt = caption || 'notion image' + const alt = altText || caption || 'notion image' content = (