feat: cool age counter

This commit is contained in:
trafficlunar 2025-05-09 14:25:03 +01:00
parent ade8d0512c
commit f2eed91109
2 changed files with 26 additions and 1 deletions

22
src/components/Age.svelte Normal file
View file

@ -0,0 +1,22 @@
<script lang="ts">
import { onMount } from "svelte";
let age = $state("");
onMount(() => {
const interval = setInterval(() => {
// only people who can read code can see my birthday
const birthday = new Date("03/02/2010");
const currentDate = new Date();
const diffInMs = currentDate.getTime() - birthday.getTime();
const msInYear = 365.25 * 24 * 60 * 60 * 1000;
age = (diffInMs / msInYear).toFixed(14);
}, 10);
return () => clearInterval(interval);
});
</script>
<span class="font-mono">{age}</span>

View file

@ -1,6 +1,7 @@
---
import Layout from "../layouts/Layout.astro";
import Age from "../components/Age.svelte";
import Projects from "../components/Projects.svelte";
import Tools from "../components/Tools.astro";
@ -11,7 +12,9 @@ import LocationIcon from "../assets/icons/location.svg";
<Layout>
<section>
<legend>about</legend>
<p>Hey there, I'm <strong class="text-peach">trafficlunar</strong>. I'm a 15 year old self-proclaimed full-stack developer and sysadmin.</p>
<p>
Hey there, I'm <strong class="text-peach">trafficlunar</strong>. I'm a <Age client:only /> year old self-proclaimed full-stack developer and sysadmin.
</p>
<p>You can view what I'm currently doing by going <a href="/status" class="link">here</a>.</p>
<div class="flex gap-1 mt-2">