mergeMeta()function

mergeMeta(meta1: Meta, meta2: PossibleMeta, caller: AnyCaller = mergeMeta): Meta
ParamType
meta1Meta
The existing fully-resolved Meta to merge into. required
    .rootImmutableURL
Base URL for the app (used to resolve url and set as <base> tag in <Head>). readonly
    .urlImmutableURL
URL of the current page (used to update history API and as the initial URL for routing). readonly
    .appstring
Title of the entire application. readonly
    .titlestring
Title of the current page (set as <title> in <Head> readonly
    .descriptionstring
Description of the current page. readonly
    .imagestring
readonly
    .languagestring
Language code (used for lang tag in HTML). readonly
    .cspMetaCSP
Type for a meta Content-Security-Policy tag in { resource: string[] } format. readonly
    .tagsMetaTags
Set of named meta <meta /> tags in { name: content } format. readonly
    .linksMetaLinks
Set of resolved meta <link /> tags in { rel: href } format (hrefs already absolutified to ImmutableURI). readonly
    .modulesMetaAssets
Set of resolved linked assets in (href)[] format (hrefs already absolutified to ImmutableURI). readonly
    .scriptsMetaAssets
Set of resolved linked assets in (href)[] format (hrefs already absolutified to ImmutableURI). readonly
    .stylesheetsMetaAssets
Set of resolved linked assets in (href)[] format (hrefs already absolutified to ImmutableURI). readonly
meta2PossibleMeta
The new PossibleMeta to apply on top. required
    .rootPossibleURL
Base URL for the app — accepts a string or URL, resolved with requireURL(). readonly
    .urlPossibleURI
New URL for the page.
- Resolved using requireURL() if set relative to root readonly
    .paramsPossibleURIParams
Set the params in the URL (not merged with existing params).
- Added to url after it is resolved.
- Baseically readonly
    .linksPossibleMetaLinks
Set of input meta <link /> tags in { rel: href } format, before hrefs are resolved. readonly
    .modulesPossibleMetaAssets
Set of input linked assets in (href)[] format, before hrefs are resolved. readonly
    .scriptsPossibleMetaAssets
Set of input linked assets in (href)[] format, before hrefs are resolved. readonly
    .stylesheetsPossibleMetaAssets
Set of input linked assets in (href)[] format, before hrefs are resolved. readonly
callerAnyCaller
Function to attribute thrown URL-resolution errors to (defaults to mergeMeta). Defaults to mergeMeta
Return
Meta
A new fully-resolved Meta combining both inputs.

Merge a PossibleMeta onto an existing Meta, resolving URLs and assets in the process.

  • title is merged with joinTitles().
  • url is resolved to an absolute URL, e.g. ./d/e/f + /a/b/c becomes https://d.com/a/b/c/d/e/f
  • stylesheets and links hrefs newly set in meta2 are absolutified against the merged url/root, so they stay correct no matter where they are later rendered.

Examples

mergeMeta(currentMeta, { title: "Messages", url: "./messages" })