Files
tabler/shared/astro/components/InlineScript.astro
T

18 lines
671 B
Plaintext

---
// Single shared implementation of the script emission point. The consuming
// package selects the behavior via the INLINE_PAGE_SCRIPTS vite define in its
// astro.config:
// - preview (false): renders nothing — scripts are registered via
// addPageScript() and drained by <PageScripts /> at the end of <body>,
// mirroring Eleventy's {% capture_script %} model (parity gate).
// - docs (true): emits the script inline at the component site — the docs
// layout has no drain; example markup carries its own scripts.
interface Props {
code: string;
}
const { code } = Astro.props;
---
{import.meta.env.INLINE_PAGE_SCRIPTS && <Fragment set:html={code} />}