astrobot-houston
released this
12 Feb 14:27
·
1770 commits
to main
since this release
Minor Changes
-
#9958
14ce8a6ebfc9daf951d2dca54737d857c229667c
Thanks @Princesseuh! - Adds support for using a custom tag (component) for optimized imagesStarting from this version, when a tag called
image
is used, itssrc
attribute will automatically be resolved if it's a local image. Astro will pass the resultImageMetadata
object to the underlying component as thesrc
prop. For non-local images (i.e. images using URLs or absolute paths), Astro will continue to pass thesrc
as a string.// markdoc.config.mjs import { component, defineMarkdocConfig, nodes } from '@astrojs/markdoc/config'; export default defineMarkdocConfig({ tags: { image: { attributes: nodes.image.attributes, render: component('./src/components/MarkdocImage.astro'), }, }, });
--- // src/components/MarkdocImage.astro import { Image } from 'astro:assets'; interface Props { src: ImageMetadata | string; alt: string; width: number; height: number; } const { src, alt, width, height } = Astro.props; --- <Image {src} {alt} {width} {height} />
{% image src="./astro-logo.png" alt="Astro Logo" width="100" height="100" %}