aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-03-20 22:55:13 -0500
committermat <github@matdoes.dev>2022-03-20 22:55:13 -0500
commit4f08ff00d83eee7f33e3a2c92f5dbf75aa027a27 (patch)
tree72cf524ecd2580f3e38b6c578bd21348cc521426
parentd71c36fda610550570daf64c808298c099505ad1 (diff)
downloadskyblock-stats-4f08ff00d83eee7f33e3a2c92f5dbf75aa027a27.tar.gz
skyblock-stats-4f08ff00d83eee7f33e3a2c92f5dbf75aa027a27.tar.bz2
skyblock-stats-4f08ff00d83eee7f33e3a2c92f5dbf75aa027a27.zip
Fix svelte issue when embedding on discord
-rw-r--r--src/lib/Head.svelte17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/lib/Head.svelte b/src/lib/Head.svelte
index e8032db..42d8170 100644
--- a/src/lib/Head.svelte
+++ b/src/lib/Head.svelte
@@ -1,4 +1,13 @@
<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 */
@@ -11,7 +20,11 @@
<svelte:head>
<title>{title}</title>
- <meta name="description" content={description} />
+ <!--
+ 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} />
- <meta property="og:description" content={metaDescription} />
+ {@html `<meta property="description" content="${serializeHtml(description)}" />`}
+ {@html `<meta property="og:description" content="${serializeHtml(metaDescription)}" />`}
</svelte:head>