aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Head.svelte
blob: 42d817083d3b17f1fb4e715509e63183a6eec848 (plain)
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
<script lang="ts">
	function serializeHtml(text: string) {
		return text
			.replace(/&/g, '&amp;')
			.replace(/</g, '&lt;')
			.replace(/>/g, '&gt;')
			.replace(/"/g, '&quot;')
			.replace(/'/g, '&#039;')
	}

	/** The title that is shown at the top of the page and in search engines */
	export let title = 'SkyBlock Stats'
	/** The description that is shown in search engines */
	export let description = ''
	/** The title that is shown in platforms like Discord */
	export let metaTitle = title
	/** The description that is shown in platforms like Discord */
	export let metaDescription = description
</script>

<svelte:head>
	<title>{title}</title>
	<!--
		svelte puts "\n" instead of actual newlines so we have to do this hack :(
		if we don't do this it looks bad on discord and probably other places
	-->
	<meta property="og:title" content={metaTitle} />
	{@html `<meta property="description" content="${serializeHtml(description)}" />`}
	{@html `<meta property="og:description" content="${serializeHtml(metaDescription)}" />`}
</svelte:head>