mirror of
https://github.com/alam00000/bentopdf.git
synced 2026-11-05 11:52:48 +01:00
A build with a custom SITE_URL failed seo-audit on the blog pages: generate-blog.mjs hard-coded https://www.bentopdf.com, and the hand-written blog/author-alam.html carries that origin literally while generate-i18n-pages.mjs only rewrites top-level pages. generate-blog.mjs now reads SITE_URL like its sibling scripts, and enhance-seo-pages.mjs rebases the default origin in dist/blog/*.html to SITE_URL (dist only, no-op for the default URL) through a small side-effect-free helper, scripts/site-origin.mjs, covered by src/tests/site-origin.test.ts.
20 lines
789 B
JavaScript
20 lines
789 B
JavaScript
/**
|
|
* The public origin the build writes into canonical / og:url / JSON-LD URLs.
|
|
* Self-hosters set SITE_URL at build time; the default is the official site.
|
|
*/
|
|
export const DEFAULT_SITE_URL = 'https://www.bentopdf.com';
|
|
|
|
const DEFAULT_ORIGIN_RE = /https:\/\/www\.bentopdf\.com(?![\w.-])/g;
|
|
|
|
/**
|
|
* Rewrites absolute URLs on the default origin to `siteUrl` (no trailing
|
|
* slash). Used for hand-written pages that carry the official origin
|
|
* literally, so a build with a custom SITE_URL emits canonicals on its own
|
|
* host. Other hosts, including look-alikes such as
|
|
* `https://www.bentopdf.com.example`, are left untouched.
|
|
*/
|
|
export function rebaseDefaultOrigin(html, siteUrl) {
|
|
if (siteUrl === DEFAULT_SITE_URL) return html;
|
|
return html.replace(DEFAULT_ORIGIN_RE, siteUrl);
|
|
}
|