--- interface Props { src: string; title?: string; desc?: string; caption?: string; frameless?: boolean; wide?: boolean; align?: "left" | "center" | "right"; id?: string; data?: string | string[]; config?: any; downloadable?: boolean; } const { src, title, desc, caption, frameless = false, wide = false, align = "left", id: providedId, data, config, downloadable = true, } = Astro.props as Props; // Generate filename from src (used for download and as default ID) const downloadFilename = src.replace(/\.html$/, '').replace(/^.*\//, ''); // Use provided ID or generate from filename const id = providedId || downloadFilename; // Load all .html embeds under src/content/embeds/** as strings (dev & build) const embeds = (import.meta as any).glob("../content/embeds/**/*.html", { query: "?raw", import: "default", eager: true, }) as Record; function resolveFragment(requested: string): string | null { // Allow both "banner.html" and "embeds/banner.html" const needle = requested.replace(/^\/*/, ""); for (const [key, html] of Object.entries(embeds)) { if ( key.endsWith("/" + needle) || key.endsWith("/" + needle.replace(/^embeds\//, "")) ) { return html; } } return null; } const html = resolveFragment(src); const mountId = `frag-${Math.random().toString(36).slice(2)}`; const dataAttr = Array.isArray(data) ? JSON.stringify(data) : typeof data === "string" ? data : undefined; const configAttr = typeof config === "string" ? config : config != null ? JSON.stringify(config) : undefined; // Apply the ID to the HTML content if provided const htmlWithId = id && html ? html.replace(/
]*>/, `
`) : html; --- { html ? (
{title && (
{title}
)}
{downloadable && ( )}
{(desc || caption) && (
)}
) : (
Embed not found

The requested embed could not be loaded: {src}

) }