aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Home/HeadTitle.svelte
blob: 73cf3e3d2e280a1195316e52553fd3ce9edae4de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<script lang="ts">
import { siteUrl } from "$lib/Utility/appOrigin";
import locale from "$stores/locale";
import type { Locale } from "$lib/Locale/layout";

type HeadTitleKey = keyof NonNullable<Locale["headTitle"]>;

let {
	route = undefined,
	routeKey = undefined,
	path = "/",
}: {
	route?: string;
	routeKey?: HeadTitleKey;
	path?: string;
} = $props();

const resolved = $derived(
	routeKey ? ($locale().headTitle?.[routeKey] ?? routeKey) : route,
);
const title = $derived((resolved ? `${resolved} • ` : "") + "due.moe");
</script>

<svelte:head>
  <!-- Facebook -->
  <meta name="og:url" property="og:url" content={siteUrl(path)} />
  <meta name="og:title" property="og:title" content={title} />

  <!-- Twitter -->
  <meta name="twitter:url" property="twitter:url" content={siteUrl(path)} />
  <meta name="twitter:title" property="twitter:title" content={title} />

  <title>{title}</title>
</svelte:head>