diff options
Diffstat (limited to 'src/routes')
-rw-r--r-- | src/routes/+layout.ts | 1 | ||||
-rw-r--r-- | src/routes/+page.svelte | 12 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts new file mode 100644 index 0000000..189f71e --- /dev/null +++ b/src/routes/+layout.ts @@ -0,0 +1 @@ +export const prerender = true; diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 3b2ef88..093347f 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -2,8 +2,8 @@ import { DateTime } from "luxon"; const getCurrentYear = () => DateTime.now().year; - const getRelative = (year) => - DateTime.local(year).toRelative({ locale: "en" }); + const getRelative = (year: number) => + DateTime.local(year).toRelative({ locale: "en" })!; let year = $state(getCurrentYear()); let sqrt = $derived(year ** 0.5); @@ -12,12 +12,14 @@ let nextSqrt = $derived(isPerfectSquare ? sqrt + 1 : Math.ceil(sqrt)); let last = $derived(lastSqrt ** 2); let next = $derived(nextSqrt ** 2); - let nextRelative = $state(getRelative(next)); + let nextRelative: string = $state(""); - setInterval(() => { + const update = () => { year = getCurrentYear(); nextRelative = getRelative(next); - }, 500); + }; + update(); + setInterval(update, 500); </script> <div id="container"> |