DocumentOptions
Options of the generated document.
Options of the generated document.
Import#
ts
import type { DocumentOptions } from "@shadow-js/dusk/server";
Signature#
ts
interface DocumentOptions {
/** `<html lang>`. Default `"en"`. */
readonly lang?: string;
/** Id of the element the app is rendered into. Default `"app"`. */
readonly rootId?: string;
/**
* `class` of `<body>`, the same on every page (a fixed string: never put request data in it). Default: none.
* Set it when the root layout styles the body (the `className` of Next.js's `<body>`).
*/
readonly bodyClass?: string;
/**
* Extra markup for `<head>`. Trusted HTML.
*
* A string is the same for every request: never put request data in it. A function runs for
* every page response and receives the request event, so it can use `event.nonce` (the CSP nonce
* of this response, which an inline script needs), `event.document` or the request's cookies.
* It must return a string; escape anything that comes from the request. If it throws or returns
* something else, the error is reported (phase `"head"`) and the page renders without it.
*
* @example
* document: { head: (event) => themeScriptTag({ nonce: event.nonce }) }
*/
readonly head?: string | ((event: RequestEvent) => string);
}
Members#
| Name | Type | Description |
|---|---|---|
lang? |
readonly lang?: string |
<html lang>. Default "en". |
rootId? |
readonly rootId?: string |
Id of the element the app is rendered into. Default "app". |
bodyClass? |
readonly bodyClass?: string |
class of <body>, the same on every page (a fixed string: never put request data in it). Default: none. Set it when the root layout styles the body (the className of Next.js's <body>). |
head? |
readonly head?: string | ((event: RequestEvent) => string) |
Extra markup for <head>. Trusted HTML. A string is the same for every request: never put request data in it. A function runs for every page response and receives the request event, so it can use event.nonce (the CSP nonce of this response, which an inline script needs), event.document or the request's cookies. It must return a string; escape anything that comes from the request. If it throws or returns something else, the error is reported (phase "head") and the page renders without it. |