feat: Add API key support

This commit is contained in:
2023-06-20 01:47:00 +02:00
parent 5c1ed32cb6
commit eac88b2ec3
14 changed files with 406 additions and 75 deletions

View 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>