diff --git a/backend/helpers/appShell.ts b/backend/helpers/appShell.ts index 470a9c210..dd0d171a7 100644 --- a/backend/helpers/appShell.ts +++ b/backend/helpers/appShell.ts @@ -71,6 +71,16 @@ const HOME_PATH = 'home' /** The element the injected copy is wrapped in. `frontend/index.html` styles it; `main.js` removes it. */ const PRERENDER_ID = 'wiki-prerender' +/** + * The `` : '' + ] + .filter(Boolean) + .join('\n '), + body: theme?.injectBody?.trim() ?? '' + } +} + /** * The document to answer a request for the app shell with. * * Every request gets a head describing the page at its URL; which page that is, and what else travels * with it, is what `fragmentsForCrawler` and `fragmentsForBrowser` differ about. * + * The site's own theme injections travel with it (`themeInjections`), which is what puts the CSS + * override and the head and body HTML from **Admin → Theme** into the document — the head ones after + * everything describing the page, so that an override is the last stylesheet in the document. + * * Only the public half is cached, and the shell is never cached: the shell is re-read per request so * that `npm run build` in `frontend/` takes effect immediately, which a cached whole document would - * have delayed by the TTL, and the two string insertions that combine them are nothing next to a - * database read. Both insertions use a replacer function rather than a replacement string — a page - * containing `$&` would otherwise rewrite itself as it was inserted. + * have delayed by the TTL, and the string insertions that combine them are nothing next to a database + * read. Every insertion uses a replacer function rather than a replacement string — a page, or an + * injection, containing `$&` would otherwise rewrite itself as it was inserted. * * @param shell The compiled `assets/index.html`, as read for this request */ @@ -459,9 +512,11 @@ export async function renderAppShell( where there is not, so that a shell built without one is enriched rather than silently skipped. */ const withoutTitle = shell.replace(/[ \t]*