12 lines
397 B
TypeScript
12 lines
397 B
TypeScript
// Per-page data Django injects via `{{ bootstrap|json_script:"bootstrap-data" }}`
|
|
// in templates/app.html. Read once at boot, before the router/app are created.
|
|
export const bootstrap: Record<string, unknown> = (() => {
|
|
const el = document.getElementById("bootstrap-data");
|
|
if (!el?.textContent) return {};
|
|
try {
|
|
return JSON.parse(el.textContent);
|
|
} catch {
|
|
return {};
|
|
}
|
|
})();
|