From b079ded266b5857f494b6def04891a81f866eda0 Mon Sep 17 00:00:00 2001 From: AdrianoDev Date: Sun, 5 Jul 2026 15:46:11 +0200 Subject: [PATCH] feat: componenti T e TImg per contenuti taggati --- src/components/content/T.astro | 11 +++++++++++ src/components/content/TImg.astro | 14 ++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/components/content/T.astro create mode 100644 src/components/content/TImg.astro diff --git a/src/components/content/T.astro b/src/components/content/T.astro new file mode 100644 index 0000000..41cefd3 --- /dev/null +++ b/src/components/content/T.astro @@ -0,0 +1,11 @@ +--- +import { resolveContent } from '../../lib/content'; +interface Props { tag: string; as?: string; class?: string } +const { tag, as = 'span', class: cls } = Astro.props; +const Tag = as; +const c = resolveContent(tag); +const classes = [cls, c.classes].filter(Boolean).join(' ') || undefined; +--- +{c.type === 'html' + ? + : {c.value}} diff --git a/src/components/content/TImg.astro b/src/components/content/TImg.astro new file mode 100644 index 0000000..6c92a75 --- /dev/null +++ b/src/components/content/TImg.astro @@ -0,0 +1,14 @@ +--- +import { Image } from 'astro:assets'; +import type { ImageMetadata } from 'astro'; +import { getImageOverride } from '../../lib/content'; +interface Props { + tag: string; src: ImageMetadata; alt: string; + class?: string; loading?: 'lazy' | 'eager'; widths?: number[]; sizes?: string; +} +const { tag, src, alt, class: cls, ...rest } = Astro.props; +const override = getImageOverride(tag); +--- +{override + ? {alt} + : {alt}}