From a8362fa88f4aa7041a29d6ba2fcdc173e8fb6322 Mon Sep 17 00:00:00 2001 From: tobias Date: Sun, 19 May 2024 08:50:00 +0200 Subject: [PATCH] Add alt attribute to imgs --- astro/src/components/Content.astro | 8 ++++---- astro/src/utils/helpers.ts | 3 ++- payload/src/collections/Media.ts | 1 + payload/src/collections/Posts.ts | 7 ++----- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/astro/src/components/Content.astro b/astro/src/components/Content.astro index d2822d9..03a3a87 100644 --- a/astro/src/components/Content.astro +++ b/astro/src/components/Content.astro @@ -6,11 +6,11 @@ const { content } = Astro.props; const contentArray = getContentArray(content); --- -
+
{ contentArray.map((value) => { if (typeof value === "string") { - return
; + return
; } else { return ( hallo ); } }) } -
+ diff --git a/astro/src/utils/helpers.ts b/astro/src/utils/helpers.ts index 391d90f..a2430e6 100644 --- a/astro/src/utils/helpers.ts +++ b/astro/src/utils/helpers.ts @@ -12,12 +12,13 @@ export const getContentArray = (content: any) => { src: node.value.filename, width: `${node.value.width}`, height: `${node.value.height}`, + alt: `${node.value.alt}`, }), }, }).replaceAll("

", "

 

"); const htmlImageArray: ( | string - | { src: string; width: number; height: number } + | { src: string; width: number; height: number, alt: string } )[] = []; let lastIndex = 0; while (true) { diff --git a/payload/src/collections/Media.ts b/payload/src/collections/Media.ts index df3e2a0..dd53854 100644 --- a/payload/src/collections/Media.ts +++ b/payload/src/collections/Media.ts @@ -18,6 +18,7 @@ export const Media: CollectionConfig = { { name: "alt", type: "text", + required: true }, ], }; diff --git a/payload/src/collections/Posts.ts b/payload/src/collections/Posts.ts index 3384ed8..e48cb5a 100644 --- a/payload/src/collections/Posts.ts +++ b/payload/src/collections/Posts.ts @@ -38,10 +38,7 @@ const Posts: CollectionConfig = { { name: "title", type: "text", - }, - { - name: "hallo", - type: "text", + required: true }, { name: "publishedDate", @@ -59,7 +56,7 @@ const Posts: CollectionConfig = { media: { fields: [ { - name: "imagel", + name: "image", type: "upload", relationTo: "media", required: true,