-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add canonical link setup (#266)
## Why? This pull request automates the addition of the canonical meta tag to every page within the website using the `<link/>` tag. ## How? - For the docs pages, make sure the slugs passed down to the layout code to ensure appropriation of the URLs. - Used the custom function ` generateCanonicalUrl(baseUrl: string, slug?: string)` to handle canonical URLs for the base layouts ## Tickets? - [Self-referencing Canonical tags](https://linear.app/fleekxyz/issue/MKTG-234/self-referencing-canonical-tags) ## Contribution checklist? - [x] The commit messages are detailed - [x] The `build` command runs locally - [x] Assets or static content are linked and stored in the project - [x] Document filename is named after the slug - [x] You've reviewed spelling using a grammar checker - [x] For documentation, guides or references, you've tested the commands and steps - [x] You've done enough research before writing ## Security checklist? - [x] Sensitive data has been identified and is being protected properly - [x] Injection has been prevented (parameterized queries, no eval or system calls) - [x] The Components are escaping output (to prevent XSS) --------- Co-authored-by: Helder Oliveira <[email protected]>
- Loading branch information
1 parent
e0c7cd1
commit eb1205e
Showing
7 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { getSiteUrl } from './url'; | ||
|
||
const BASE_URL = getSiteUrl(); | ||
|
||
export function generateCanonicalUrl(slug?: string) { | ||
if (!slug) return `${BASE_URL}/`; | ||
|
||
const sanitizedSlug = slug | ||
.trim() | ||
.split('/') | ||
.filter((item) => item) | ||
.join('/'); | ||
|
||
return `${BASE_URL}/${sanitizedSlug}/`; | ||
} |