withPwa

tcmts.cli.web.withPwa · #s7hr24e7 · term · runs anywhere

A PWA's page: its title the app's name, and the head tags its manifest gives (webManifest), then PWA_SCRIPT.

import { escapeHtml, PWA_SCRIPT } from "#codebase/tcmts/cli/web";

export function withPwa(html: string, head: string[], title: string): string {
  return html
    .replace(/<title>[^<]*<\/title>/, () => `<title>${escapeHtml(title)}</title>`)
    .replace("</head>", () => `${[...head, PWA_SCRIPT].join("\n")}\n</head>`);
}

uses

used by