[]previous and next page

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 with on, a reserved marker attribute, an attribute value that is not a string, number or boolean, children on a tag other than title and style, or a key on anything but a style. The production messages start with SHADOW_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