generated from avior/template-web-astro
11 lines
322 B
TypeScript
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)
|
|
}
|