INNER CODE UNIT · JavaScript

writeStaticRedirect

namastack/namastack-outbox · namastack-outbox-docs/plugins/canonical-fix-plugin.js:163

function writeStaticRedirect(filePath, targetPage, targetPath, siteUrl) {
  const canonicalUrl = new URL(targetPage, siteUrl).toString();

  fs.mkdirSync(path.dirname(filePath), {recursive: true});
  fs.writeFileSync(
    filePath,
    [
      '<!doctype html>',
      '<html lang="en">',
      '<head>',
      '<meta charset="utf-8">',
      '<meta name="robots" content="noindex">',
      `<link rel="canonical" href="${canonicalUrl}">`,
      `<meta http-equiv="refresh" content="0; url=${targetPath}">`,
      '<title>Documentation moved</title>',
      '</head>',
      '<body>',
      `<p>This documentation moved to <a href="${targetPath}">${targetPath}</a>.</p>`,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…