normalizeTags
Normalizes what useHead receives: one description, a list, or nothing.
Normalizes what useHead receives: one description, a list, or nothing.
Import#
ts
import { normalizeTags } from "@shadow-js/web/server";
Signature#
ts
function normalizeTags(input: unknown): NormalizedTag[]
Parameters#
| Name | Description |
|---|---|
input |
A description, a list of them, or null, undefined or false for none. |
Returns#
The normalized tags, in order.
Throws#
- TypeError when any description is invalid: an unknown tag (including
script), an attribute name that is not valid or starts withon, a reserved marker attribute, an attribute value that is not a string, number or boolean, children on a tag other thantitleandstyle, or a key on anything but astyle. The production messages start withSHADOW_HEAD_.
Examples#
ts
import { normalizeTags } from "@shadow-js/web/server";
const tags = normalizeTags([
{ tag: "title", children: "A" },
{ tag: "base", props: { href: "/" } },
]);
console.log(tags.length); // 2