--- interface Props { src: string; title?: string; desc?: string; frameless?: boolean; align?: 'left' | 'center' | 'right'; id?: string, data?: string | string[], config?: any } const { src, title, desc, frameless = false, align = 'left', id, data, config } = Astro.props as Props; // 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}
}
{desc &&
}
) : (
) }