INNER CODE UNIT · JavaScript

canonicalRegex

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

      const canonicalRegex = new RegExp(
        `(<link[^>]*rel="canonical"[^>]*href=")${escapeRegExp(versionRoot)}([^"]*")`
      );
      const nextHtml = html.replace(canonicalRegex, `$1${latestRoot}$2`);

      if (nextHtml !== html) {
        fs.writeFileSync(filePath, nextHtml, 'utf-8');
      }
    }
  }
}

function createLegacyDocumentationRedirects(docsDir, outDir, siteUrl, baseUrl, docsPath) {
  if (!fs.existsSync(docsDir)) return;

  for (const sourceFile of findHtmlFiles(docsDir)) {
    const relativePath = path.relative(docsDir, sourceFile);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…