Skip to content

Commit

Permalink
fixup! fixup! fix(spas): set canonical url
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner committed Apr 29, 2024
1 parent fc1ac04 commit 30cfed4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions build/spas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,15 +465,15 @@ async function fetchLatestNews() {
}

function renderPage(url: string, context: any) {
const html = renderHTML(url, context);
let html = renderHTML(url, context);
html = html.replace(
`<link rel="canonical" href="${BASE_URL}"/>`,
`<link rel="canonical" href="${BASE_URL}${url}"/>`
);
// Better safe than sorry.
html.replace(
html = html.replace(
`<link rel="canonical" href="https://developer.mozilla.org"/>`,
`<link rel="canonical" href="https://developer.mozilla.org${url}"/>`
);
html.replace(
`<link rel="canonical" href="${BASE_URL}"/>`,
`<link rel="canonical" href="${BASE_URL}${url}"/>`
);
return html;
}

0 comments on commit 30cfed4

Please sign in to comment.