Skip to content

Commit

Permalink
feat: add canonical to all pages
Browse files Browse the repository at this point in the history
  • Loading branch information
simenandre committed Jun 26, 2023
1 parent bfd9bc8 commit 43658e9
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/components/metadata.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
export let description: string | undefined = undefined;
export let data: MetaTagsProps = {};
export let seo: Seo | null = null;
export let path: string | undefined = undefined;
export let defaultImage = '/assets/bjerk-default-seo.png';
Expand All @@ -27,6 +28,7 @@
{...data}
titleTemplate={data.title ? '%s – Bjerk' : 'Bjerk - Digitale produktutviklere'}
description={seo?.description ?? description ?? data.description ?? defaultDescription}
canonical={path ? new URL(path, 'https://bjerk.io').toString() : undefined}
openGraph={{
site_name: 'Bjerk',
title: seo?.title ?? data.title ?? 'Bjerk',
Expand All @@ -35,7 +37,8 @@
{
url: image
}
]
],
...(path ? { canonical: new URL(path, 'https://bjerk.io').toString() } : {})
}}
twitter={{
cardType: 'summary_large_image',
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(default)/about/principles/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Metadata from '$components/metadata.svelte';
</script>

<Metadata title="Prinsipper" />
<Metadata title="Prinsipper" path="/about/principles" />

<div class="container">
<div class="section">
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(default)/contact/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Employees from '$components/employees.svelte';
</script>

<Metadata title="Om oss" />
<Metadata title="Om oss" path="/contact" />

<div class="container">
<div class="section elevator">
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(default)/privacy/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Metadata from '../../../components/metadata.svelte';
</script>

<Metadata title="Personvernerklæring" />
<Metadata title="Personvernerklæring" path="/privacy" />

<div class="content">
<h1>Personvern­erklæring</h1>
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(default)/projects/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
export let data: PageData;
</script>

<Metadata title="Prosjekter" />
<Metadata title="Prosjekter" path="/projects" />

<div class="container projects">
{#each data.projects as project}
Expand Down
1 change: 1 addition & 0 deletions src/routes/(default)/projects/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
title={project.name}
description={project.description}
seo={project.seo}
path={`/projects/${project.slug?.current}`}
defaultImage={`https://bjerk.io/assets/graph/${project.slug?.current}.png`}
/>

Expand Down
2 changes: 1 addition & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import Hero from './hero.svelte';
</script>

<Metadata />
<Metadata path="/" />

<div class="homepage-container">
<div class="container">
Expand Down

0 comments on commit 43658e9

Please sign in to comment.