2024-05-14 11:23:07 +00:00

11 lines
322 B
TypeScript

/**
* 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)
}