diff --git a/web/cloudflare/handler/contribution.ts b/web/cloudflare/handler/contribution.ts index f9963ac0f..d07b975bd 100644 --- a/web/cloudflare/handler/contribution.ts +++ b/web/cloudflare/handler/contribution.ts @@ -56,7 +56,8 @@ export const handleContributionRequest: PagesFunction = async (context) => const newData = htmlTemplate .replace(/{{template-title}}/g, pageTitle) .replace(/{{template-description}}/g, localize("contribute-description")) - .replace(/{{template-lang}}/g, language); + .replace(/{{template-lang}}/g, language) + .replace(/{{template-canonical}}/g, `${fullstackConfig.web.url}${pathName}`); return new Response(newData, { headers: { "content-type": "text/html; charset=utf-8" } }); } catch (error) { diff --git a/web/cloudflare/handler/contributor.ts b/web/cloudflare/handler/contributor.ts index 3bdbe700d..0c1d69557 100644 --- a/web/cloudflare/handler/contributor.ts +++ b/web/cloudflare/handler/contributor.ts @@ -55,7 +55,8 @@ export const handleContributorRequest: PagesFunction = async (context) => { const newData = htmlTemplate .replace(/{{template-title}}/g, pageTitle) .replace(/{{template-description}}/g, localize("team-description")) - .replace(/{{template-lang}}/g, language); + .replace(/{{template-lang}}/g, language) + .replace(/{{template-canonical}}/g, `${fullstackConfig.web.url}${pathName}`); return new Response(newData, { headers: { "content-type": "text/html; charset=utf-8" } }); } catch (error) { diff --git a/web/cloudflare/handler/project.ts b/web/cloudflare/handler/project.ts index b0c73d5a9..64cd8d729 100644 --- a/web/cloudflare/handler/project.ts +++ b/web/cloudflare/handler/project.ts @@ -53,7 +53,8 @@ export const handleProjectRequest: PagesFunction = async (context) => { const newData = htmlTemplate .replace(/{{template-title}}/g, pageTitle) .replace(/{{template-description}}/g, localize("projects-description")) - .replace(/{{template-lang}}/g, language); + .replace(/{{template-lang}}/g, language) + .replace(/{{template-canonical}}/g, `${fullstackConfig.web.url}${pathName}`); return new Response(newData, { headers: { "content-type": "text/html; charset=utf-8" } }); } catch (error) { diff --git a/web/src/_build/gen-multiple-htmls.ts b/web/src/_build/gen-multiple-htmls.ts index a0c2e5929..2d1cc073b 100644 --- a/web/src/_build/gen-multiple-htmls.ts +++ b/web/src/_build/gen-multiple-htmls.ts @@ -58,7 +58,10 @@ allPages.forEach((pageInfo) => { newHtml = newHtml.replace(/{{keywords}}/g, pageInfo.keywords); newHtml = newHtml.replace(/{{title}}/g, pageInfo.title); newHtml = newHtml.replace(/{{description}}/g, pageInfo.description); - newHtml = newHtml.replace(/{{canonical}}/g, `${config.web.url}${pageInfo.uri}`); + newHtml = newHtml.replace( + /{{canonical}}/g, + pageInfo.canonicalUrl || `${config.web.url}${pageInfo.uri}`, + ); newHtml = newHtml.replace(/{{ogImage}}/g, pageInfo.ogImage); newHtml = newHtml.replace(/{{sentryOrigin}}/g, `https://${SENTRY_ORIGIN}`); diff --git a/web/src/_build/pages/index.ts b/web/src/_build/pages/index.ts index f225046d5..8e7e052e9 100644 --- a/web/src/_build/pages/index.ts +++ b/web/src/_build/pages/index.ts @@ -6,6 +6,7 @@ import { templatePages } from "./template-pages"; export interface PageInfo { uri: string; + canonicalUrl?: string; title: string; description: string; ogImage: string; diff --git a/web/src/_build/pages/template-pages.ts b/web/src/_build/pages/template-pages.ts index f31694c97..e2348ad09 100644 --- a/web/src/_build/pages/template-pages.ts +++ b/web/src/_build/pages/template-pages.ts @@ -9,5 +9,6 @@ export const templatePages: PageInfo[] = [ "https://images.unsplash.com/photo-1527285341945-715b98b98ea2?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1200&h=627&q=80", keywords: "open-source, algeria, dzcode", lang: "{{template-lang}}" as unknown as PageInfo["lang"], + canonicalUrl: "{{template-canonical}}", }, ];