Skip to content

Commit 65e0242

Browse files
feat(seo): revamp SEO
1 parent 54b43a8 commit 65e0242

File tree

7 files changed

+81
-15
lines changed

7 files changed

+81
-15
lines changed

src/lib/config.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/routes/+layout.svelte

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
<script lang="ts">
22
import "../app.css";
3-
import { onMount } from "svelte";
43
import { scrollY } from "svelte/reactivity/window";
54
import { dev } from "$app/environment";
5+
import { page } from "$app/state";
6+
import { deepMerge, MetaTags } from "svelte-meta-tags";
67
import { ChevronDown, type Icon, Monitor, Moon, Sun, X } from "@lucide/svelte";
78
import { ProgressBar } from "@prgm/sveltekit-progress-bar";
89
import { ModeWatcher, resetMode, setMode } from "mode-watcher";
910
import { news } from "$lib/news/news.json";
10-
import { FAVICON_URL } from "$lib/config";
1111
import { cn } from "$lib/utils";
1212
import ScreenSize from "$lib/components/ScreenSize.svelte";
1313
import { buttonVariants, Button } from "$lib/components/ui/button";
1414
import * as DropdownMenu from "$lib/components/ui/dropdown-menu";
1515
16-
let { children } = $props();
16+
let { data, children } = $props();
17+
18+
// SEO
19+
let metaTags = $derived(deepMerge(data.baseMetaTags, page.data.pageMetaTags));
1720
1821
// Theme selector
1922
type Theme = {
@@ -48,7 +51,7 @@
4851
return JSON.parse(localStorage.getItem(closedNewsKey) ?? "[]") as (typeof news)[number]["id"][];
4952
}
5053
51-
onMount(() => {
54+
$effect(() => {
5255
// Theme
5356
theme =
5457
"mode-watcher-mode" in localStorage
@@ -69,6 +72,7 @@
6972
{/if}
7073
<ModeWatcher />
7174
<ProgressBar class="text-primary" zIndex={100} />
75+
<MetaTags {...metaTags} />
7276

7377
<header
7478
class={[
@@ -89,7 +93,11 @@
8993
<div class="mx-auto flex h-14 w-full items-center px-8">
9094
<!-- Left part -->
9195
<a href="/" class="flex items-center gap-2">
92-
<img src={FAVICON_URL} alt="Svelte" class="size-8" />
96+
<img
97+
src="https://raw.githubusercontent.com/sveltejs/branding/master/svelte-logo.svg"
98+
alt="Svelte"
99+
class="size-8"
100+
/>
93101
<span class="hidden text-xl font-semibold xs:inline-block">
94102
Svelte
95103
<span class="text-primary">Changelog</span>

src/routes/+layout.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
11
import { injectSpeedInsights } from "@vercel/speed-insights/sveltekit";
2+
import type { MetaTagsProps } from "svelte-meta-tags";
23

34
injectSpeedInsights();
5+
6+
const siteName = "Svelte Changelog";
7+
8+
export function load({ url, data }) {
9+
return {
10+
...data,
11+
siteName,
12+
baseMetaTags: Object.freeze({
13+
title: "Loading...",
14+
titleTemplate: `%s | ${siteName}`,
15+
description: "A nice UI to stay up-to-date with Svelte releases",
16+
canonical: new URL(url.pathname, url.origin).href,
17+
openGraph: {
18+
type: "website",
19+
url: new URL(url.pathname, url.origin).href,
20+
locale: "en_US",
21+
siteName,
22+
images: [
23+
{
24+
url: "https://svelte.dev/favicon.png",
25+
width: 128,
26+
height: 128,
27+
alt: "Svelte logo"
28+
}
29+
]
30+
},
31+
twitter: {
32+
creator: "@probably_coding",
33+
cardType: "summary" as const,
34+
description: "A nice UI to stay up-to-date with Svelte releases"
35+
},
36+
keywords: ["svelte", "changelog", "svelte changelog", "sveltekit"],
37+
additionalRobotsProps: {
38+
noarchive: true
39+
}
40+
}) satisfies MetaTagsProps
41+
};
42+
}

src/routes/[pullOrIssue=poi]/[org]/[repo]/[id=number]/+page.svelte

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
);
1212
</script>
1313

14-
<svelte:head>
15-
<title>
16-
Detail of {data.itemMetadata.org}/{data.itemMetadata.repo}#{data.itemMetadata.id} | Svelte Changelog
17-
</title>
18-
</svelte:head>
19-
2014
<PageRenderer
2115
metadata={{
2216
org: data.itemMetadata.org,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { MetaTagsProps } from "svelte-meta-tags";
2+
3+
export function load({ data }) {
4+
return {
5+
...data,
6+
pageMetaTags: Object.freeze({
7+
title: `Detail of ${data.itemMetadata.org}/${data.itemMetadata.repo}#${data.itemMetadata.id}`
8+
}) satisfies MetaTagsProps
9+
};
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { MetaTagsProps } from "svelte-meta-tags";
2+
3+
export function load({ data }) {
4+
return {
5+
...data,
6+
pageMetaTags: Object.freeze({
7+
title: data.currentPackage.pkg.name
8+
}) satisfies MetaTagsProps
9+
};
10+
}

src/routes/packages/+page.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { MetaTagsProps } from "svelte-meta-tags";
2+
3+
export function load() {
4+
return {
5+
pageMetaTags: Object.freeze({
6+
title: "All Packages"
7+
}) satisfies MetaTagsProps
8+
};
9+
}

0 commit comments

Comments
 (0)