Skip to content

Commit fadfe53

Browse files
committed
chore: website seo
1 parent 5272e9e commit fadfe53

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

apps/web/src/components/AdSlot.svelte

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<script lang="ts">
2-
$effect(() => {
3-
// @ts-ignore
4-
(adsbygoogle = window.adsbygoogle || []).push({});
5-
});
2+
import { navigating } from '$app/stores';
3+
$: if ($navigating) {
4+
try {
5+
// @ts-ignore
6+
(adsbygoogle = window.adsbygoogle || []).push({});
7+
} catch (e) {}
8+
}
69
</script>
710

811
<ins

apps/web/src/components/SEO.svelte

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script lang="ts">
2+
let siteData = {
3+
title: 'Svelte Turbo',
4+
desc: "A Willin Wang's Work"
5+
};
6+
const {
7+
formatTitle = true,
8+
title = '',
9+
desc = siteData.desc
10+
} = $props<{ formatTitle?: boolean; title?: string; desc?: string }>();
11+
const formattedTitle = $derived(
12+
formatTitle ? (title ? `${title} — ${siteData.title}` : `${siteData.title}`) : title
13+
);
14+
</script>
15+
16+
<svelte:head>
17+
<title>{formattedTitle}</title>
18+
<meta name="description" content={desc} />
19+
<meta name="twitter:card" content="summary_large_image" />
20+
<meta name="twitter:title" content={formattedTitle} />
21+
<meta name="twitter:description" content={desc} />
22+
<meta property="og:title" content={formattedTitle} />
23+
<meta property="og:description" content={desc} />
24+
</svelte:head>

apps/web/src/components/mdsvex.svelte

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<script>
1+
<script lang="ts">
22
import { createTableOfContents } from '@melt-ui/svelte';
33
import Toc from './toc.svelte';
44
import AdSlot from './AdSlot.svelte';
5+
import SEO from './SEO.svelte';
56
6-
const { title, desc } = $props();
7+
const { title, desc } = $props<{ title: string; desc: string }>();
78
89
const {
910
elements: { item },
@@ -14,6 +15,10 @@
1415
});
1516
</script>
1617

18+
{#if title}
19+
<SEO {title} {desc} />
20+
{/if}
21+
1722
<div
1823
class="hero min-h-screen bg-neutral"
1924
style="background-image: url(https://willin.wang/images/bg.jpg);">

apps/web/src/routes/[[lang=locale]]/+page.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import { getPossibleLocales, locales } from '@svelte-dev/i18n';
55
import { fallbackLng } from '$lib/i8n';
66
import { page } from '$app/stores';
7+
import SEO from '$components/SEO.svelte';
8+
import { goto } from '$app/navigation';
79
810
$effect(() => {
911
const isInit = !!localStorage.getItem('lang');
@@ -20,6 +22,7 @@
2022
});
2123
</script>
2224

25+
<SEO />
2326
<div class="hero min-h-screen" style="background-image: url(https://willin.wang/images/bg.jpg);">
2427
<div class="hero-overlay bg-opacity-60"></div>
2528
<div class="hero-content text-center text-neutral-content">

0 commit comments

Comments
 (0)