feat: Add API key support
This commit is contained in:
16
src/components/Passthrough.astro
Normal file
16
src/components/Passthrough.astro
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
const json = JSON.stringify(Astro.props)
|
||||
|
||||
/**
|
||||
* note: you MUST only pass simple items that can go in JSON format natively
|
||||
*/
|
||||
export function load<T extends {} = {}>(): T {
|
||||
const tag = document.querySelector<HTMLScriptElement>('#ASTRO_DATA')
|
||||
if (!tag) {
|
||||
throw new Error('could not load client variables, tag not found')
|
||||
}
|
||||
return JSON.parse(tag.innerText)
|
||||
}
|
||||
|
||||
---
|
||||
<script id="ASTRO_DATA" is:inline type="application/json" set:html={json}></script>
|
Reference in New Issue
Block a user