Skip to content
17 changes: 15 additions & 2 deletions static/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,22 @@
}
__sentryMark('head-start');
</script>
<link rel="preload" href="/api/client-config/" as="fetch" crossorigin />
<script>
// Django inlines a class for the user theme, but SPA mode requires manual init.
// Default to `.theme-system` and replace with user theme as soon as possible.
const BOOTSTRAP_URL = '/api/client-config/';
async function applySpaTheme() {
const data = await fetch(BOOTSTRAP_URL).then(res => res.json());
const theme = data.user?.options.theme;
if (theme) {
document.body.classList.replace('theme-system', `theme-${theme}`);
}
}
applySpaTheme();
</script>
</head>

<body>
<body class="theme-system">
<% if (htmlWebpackPlugin.options.unsupportedBrowser) { %>
<style>.unsupported-browser { display: none; }</style>
<div class="unsupported-browser">
Expand Down
Loading