From ce2230a67a72b9850b37576cb441a56ff3b71ee8 Mon Sep 17 00:00:00 2001
From: mat <github@matdoes.dev>
Date: Sat, 19 Mar 2022 22:52:20 -0500
Subject: Add favicon + misc fixes

---
 src/lib/BackgroundImage.svelte | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

(limited to 'src/lib/BackgroundImage.svelte')

diff --git a/src/lib/BackgroundImage.svelte b/src/lib/BackgroundImage.svelte
index fd62170..0b2f043 100644
--- a/src/lib/BackgroundImage.svelte
+++ b/src/lib/BackgroundImage.svelte
@@ -1,8 +1,10 @@
 <script lang="ts">
-	import { onDestroy } from 'svelte'
+	import { onDestroy, onMount } from 'svelte'
 	import { browser } from '$app/env'
 
 	export let url: string
+	let styleHtml = `<style class="background-image-style">:root{--background:url(${url})}</style>`
+	let serverSideRenderedStyleShown = true
 
 	function updateUrl() {
 		if (!browser) return
@@ -19,6 +21,10 @@
 
 	$: [url, updateUrl()]
 
+	onMount(() => {
+		serverSideRenderedStyleShown = false
+	})
+
 	// get rid of the body style when we leave the page
 	// not doing this will sometimes cause the background to stay
 	onDestroy(() => {
@@ -28,3 +34,9 @@
 		}
 	})
 </script>
+
+<svelte:head>
+	{#if serverSideRenderedStyleShown}
+		{@html styleHtml}
+	{/if}
+</svelte:head>
-- 
cgit 

