UNPKG

@astrojs/markdoc

Version:
26 lines (25 loc) 752 B
import { Image } from "astro:assets"; import Markdoc from "@markdoc/markdoc"; const assetsConfig = { nodes: { image: { attributes: { ...Markdoc.nodes.image.attributes, __optimizedSrc: { type: "Object" } }, transform(node, config) { const attributes = node.transformAttributes(config); const children = node.transformChildren(config); if (node.type === "image" && "__optimizedSrc" in node.attributes) { const { __optimizedSrc, ...rest } = node.attributes; return new Markdoc.Tag(Image, { ...rest, src: __optimizedSrc }, children); } else { return new Markdoc.Tag("img", attributes, children); } } } } }; export { assetsConfig };