From 6e19444bd32c271b53971eaad7377e340259100c Mon Sep 17 00:00:00 2001 From: Dawid Rycerz Date: Mon, 12 Jan 2026 19:54:27 +0100 Subject: Add alt text support --- src/components/note/Note.astro | 4 ++-- src/content.config.ts | 1 + src/loaders/pleroma.ts | 1 + src/pages/micro/rss.xml.ts | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/note/Note.astro b/src/components/note/Note.astro index 3017d2d..920cbc1 100644 --- a/src/components/note/Note.astro +++ b/src/components/note/Note.astro @@ -47,7 +47,7 @@ const { Content } = await render(note); { !isPreview && note.data.attachments && note.data.attachments.length > 0 && (
- {note.data.attachments.map((attachment: { url: string; type: string }) => ( + {note.data.attachments.map((attachment: { type: string; url: string; alt?: string }) => ( Attachment diff --git a/src/content.config.ts b/src/content.config.ts index 2ae9fbf..032011e 100644 --- a/src/content.config.ts +++ b/src/content.config.ts @@ -53,6 +53,7 @@ const micro = defineCollection({ z.object({ url: z.string(), type: z.string(), + alt: z.string().optional(), }), ) .optional(), diff --git a/src/loaders/pleroma.ts b/src/loaders/pleroma.ts index be61329..0dbb26b 100644 --- a/src/loaders/pleroma.ts +++ b/src/loaders/pleroma.ts @@ -557,6 +557,7 @@ export function pleromaLoader(config: PleromaFeedConfig): Loader { .map((attachment) => ({ url: attachment.url, type: `image/${attachment.url.split(".").pop() || "jpeg"}`, + alt: attachment.description || undefined, })); } diff --git a/src/pages/micro/rss.xml.ts b/src/pages/micro/rss.xml.ts index 1fd6f53..5b388b6 100644 --- a/src/pages/micro/rss.xml.ts +++ b/src/pages/micro/rss.xml.ts @@ -21,8 +21,8 @@ export const GET = async (context: APIContext) => { if (post.data.attachments && post.data.attachments.length > 0) { const imagesHtml = post.data.attachments .map( - (att: { url: string; type: string }) => - `

Attachment

`, + (att) => + `

${att.alt ||

`, ) .join(""); fullContent += imagesHtml; -- cgit v1.2.3