Skip to content

Fix hydration mismatch errors #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ useSeoMeta({
</script>

<template>
<body class="bg-background">
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</body>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</template>
24 changes: 0 additions & 24 deletions components/section/AboutMe.vue
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
<template>
<section class="">
<div class="lg:text-normal space-y-4 text-justify text-white sm:text-base">
<template v-if="false">
<div>
I am a
<span class="inline-block w-48">
<HeadlessTransitionRoot
as="template"
appear
:show="show"
enter="transition transform duration-300 ease-out"
enter-from="translate-y-2 opacity-0"
enter-to="translate-x-0 opacity-100"
leave="transition transform duration-300 ease-in"
leave-from="opacity-100"
leave-to="-translate-y-2 opacity-0"
>
<div
class="w-48 bg-white px-2 text-center font-extrabold tracking-wide text-black shadow-xl"
>
{{ occupation }}
</div>
</HeadlessTransitionRoot>
</span>
</div>
</template>
<div>
I help educate data engineers while building the future of data
orchestration at
Expand Down
26 changes: 8 additions & 18 deletions components/section/BlogPosts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ const props = defineProps({
<template>
<section class="bg-gradient-to-b from-background to-transparent py-2">
<div class="container mx-auto space-y-4">
<template v-if="false">
<NuxtLink
to="/articles"
class="font-milk text-xl text-white hover:underline hover:decoration-orange-500 hover:decoration-2"
>
Blog Posts
</NuxtLink>
</template>

<div class="mb-4 grid grid-cols-1 gap-4 md:grid-cols-2">
<div v-for="(article, ix) of articles" :key="ix">
Expand All @@ -27,17 +19,15 @@ const props = defineProps({
<div class="flex-1 text-lg font-bold md:text-xl">
{{ article.title }}
</div>
<div v-if="show_dates" class="text-sm font-light text-gray-400">
{{
new Date(article.date).toLocaleDateString("en-US", {
month: "long",
day: "numeric",
year: "numeric",
})
}}
</div>
<NuxtTime
v-if="show_dates"
:datetime="article.date"
class="text-sm font-light text-gray-400"
year="numeric"
month="short"
day="2-digit"
/>
</div>

<div class="line-clamp-3 text-sm text-gray-300">
{{ article.description }}
</div>
Expand Down
8 changes: 0 additions & 8 deletions components/section/Playground.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,6 @@ const filtered_links = computed(() => {
<template>
<section class="bg-gradient-to-b from-transparent to-background text-white">
<div class="container mx-auto space-y-4 py-8 text-white">
<template v-if="false">
<NuxtLink
to="/playground"
class="font-milk text-2xl text-white underline decoration-orange-500 decoration-2"
>
Experiments
</NuxtLink>
</template>

<div class="mb-4 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
<nuxt-link
Expand Down
8 changes: 8 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ export default defineNuxtConfig({
components: true,
modules: ["@nuxt/content", "@nuxtjs/tailwindcss", "nuxt-headlessui"],

app: {
head: {
bodyAttrs: {
class: 'bg-background'
}
}
},

// Optionally change the default prefix.
headlessui: {
prefix: "Headless",
Expand Down
13 changes: 7 additions & 6 deletions pages/articles/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,17 @@ function toggleCategory(cat) {

<template>
<section class="container mx-auto font-mono text-white">
<template v-if="false">
<h1 class="my-6 text-2xl font-extrabold">Blog</h1>
</template>
<div class="grid grid-cols-4 gap-4">
<div class="col-span-4 lg:col-span-3">
<div class="grid grid-cols-10 gap-y-4 lg:gap-y-6">
<template v-for="article in visibleArticles" :key="article._id">
<div class="col-span-10 lg:col-span-2">
{{ formatDate(article.date) }}
</div>
<NuxtTime
:datetime="article.date"
class="col-span-10 lg:col-span-2"
year="numeric"
month="short"
day="2-digit"
/>
<div class="col-span-10 lg:col-span-8">
<div class="flex-col space-y-2">
<NuxtLink class="text-orange-500" :to="article.path">{{
Expand Down
6 changes: 0 additions & 6 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ const data = await queryCollection("content")

<template>
<div>
<template v-if="false">
<SectionAboutMe />
</template>
<div class="bg-emerald-950 bg-[url('/images/noise.svg')]">
<template v-if="false">
<SectionInterests />
</template>
<SectionBlogPosts :articles="data" :show_dates="true" />
<SectionPlayground :limit="9" showImages linkToPlayground />
</div>
Expand Down
4 changes: 0 additions & 4 deletions pages/playground/matrix.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@
</div>
</div>

<!-- Debug -->
<div v-if="false" class="border border-gray-400 p-2">
{{ step }}
</div>
</div>
</template>

Expand Down
9 changes: 8 additions & 1 deletion pages/playground/palettes/mountains.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
<div class="select-none bg-gradient-to-b from-green-800 to-gray-800">
<div class="m-6 grid h-2/3 place-items-center">
<div class="font-mono text-white">
<div id="canvas" class="mb-2 h-96 border-2 border-white" />
<ClientOnly>
<div id="canvas" class="mb-2 h-96 border-2 border-white" />
<template #fallback>
<div class="mb-2 flex h-96 items-center justify-center border-2 border-white bg-gray-800">
<div class="text-white">Loading mountain visualization...</div>
</div>
</template>
</ClientOnly>
<div class="my-2 w-48 text-center md:w-full">
Click or tap anywhere to redraw the waves!
</div>
Expand Down
9 changes: 8 additions & 1 deletion pages/playground/palettes/variance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
<div class="grid h-screen place-items-center">
<div class="font-mono text-white">
<div class="mb-2 border-2 border-white">
<div id="canvas" />
<ClientOnly>
<div id="canvas" />
<template #fallback>
<div class="flex h-96 items-center justify-center bg-gray-800">
<div class="text-white">Loading color palette...</div>
</div>
</template>
</ClientOnly>
</div>
</div>
</div>
Expand Down
9 changes: 8 additions & 1 deletion pages/playground/plotter/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
<div class="m-8 grid place-items-center">
<div class="font-mono text-white">
<div id="canvas-container" class="mb-2 h-96 border-2 border-white">
<div id="canvas" />
<ClientOnly>
<div id="canvas" />
<template #fallback>
<div class="flex h-96 items-center justify-center bg-gray-800">
<div class="text-white">Loading sequence plotter...</div>
</div>
</template>
</ClientOnly>
</div>
<div class="my-2 md:w-full">
<textarea
Expand Down
9 changes: 8 additions & 1 deletion pages/playground/stl-model-render.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ definePageMeta({ layout: "none" });
renderer.
</div>
<div class="h-96 border-2 border-white">
<ModelPreview path="/models/mac_mini_macbook_stand.stl" />
<ClientOnly>
<ModelPreview path="/models/mac_mini_macbook_stand.stl" />
<template #fallback>
<div class="flex h-full items-center justify-center bg-gray-800">
<div class="text-white">Loading 3D model...</div>
</div>
</template>
</ClientOnly>
</div>
</div>
</template>
9 changes: 8 additions & 1 deletion pages/playground/tiling/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
<div class="grid h-screen place-items-center">
<div class="font-mono text-white">
<div class="mb-2 border-2 border-white">
<div id="canvas" />
<ClientOnly>
<div id="canvas" />
<template #fallback>
<div class="flex h-96 items-center justify-center bg-gray-800">
<div class="text-white">Loading tiling visualization...</div>
</div>
</template>
</ClientOnly>
</div>
<div class="my-2 w-48 text-center md:w-full">
m-ary tree based tiling
Expand Down
63 changes: 42 additions & 21 deletions pages/playground/waves/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,54 @@
</div>
</div>
<div class="mb-2 border-2 border-white">
<PlaygroundWave
id="canvas1"
type="sin"
:diameter="wave.diameter"
:amplitude="wave.amplitude"
:lambda="wave.lambda"
/>
<ClientOnly>
<PlaygroundWave
id="canvas1"
type="sin"
:diameter="wave.diameter"
:amplitude="wave.amplitude"
:lambda="wave.lambda"
/>
<template #fallback>
<div class="flex h-64 items-center justify-center bg-gray-800">
<div class="text-white">Loading wave visualization...</div>
</div>
</template>
</ClientOnly>
</div>
<div>y(x) = A cos((2π / λ) x)</div>
<div class="mb-2 border-2 border-white">
<PlaygroundWave
id="canvas2"
type="cos"
:diameter="wave.diameter"
:amplitude="wave.amplitude"
:lambda="wave.lambda"
/>
<ClientOnly>
<PlaygroundWave
id="canvas2"
type="cos"
:diameter="wave.diameter"
:amplitude="wave.amplitude"
:lambda="wave.lambda"
/>
<template #fallback>
<div class="flex h-64 items-center justify-center bg-gray-800">
<div class="text-white">Loading wave visualization...</div>
</div>
</template>
</ClientOnly>
</div>
<div>y(x) = A tan((2π / λ) x)</div>
<div class="border-2 border-white">
<PlaygroundWave
id="canvas3"
type="tan"
:diameter="wave.diameter"
:amplitude="wave.amplitude"
:lambda="wave.lambda"
/>
<ClientOnly>
<PlaygroundWave
id="canvas3"
type="tan"
:diameter="wave.diameter"
:amplitude="wave.amplitude"
:lambda="wave.lambda"
/>
<template #fallback>
<div class="flex h-64 items-center justify-center bg-gray-800">
<div class="text-white">Loading wave visualization...</div>
</div>
</template>
</ClientOnly>
</div>
<div class="my-2 w-48 md:w-full">
Click or tap anywhere to clear the canvas!
Expand Down
8 changes: 7 additions & 1 deletion pages/talks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ const talks = [
<h1 class="my-6 text-2xl font-extrabold">Talks</h1>
<div class="grid grid-cols-10 gap-y-6">
<template v-for="(talk, ix) in talks" :key="ix">
<div class="col-span-2">{{ formatDate(talk.date) }}</div>
<NuxtTime
:datetime="talk.date"
class="col-span-2"
year="numeric"
month="short"
day="2-digit"
/>
<div class="col-span-8">
<div class="flex-col space-y-2">
<!-- <div class=""> -->
Expand Down
4 changes: 4 additions & 0 deletions utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Warning! This utility was created before becoming aware of <NuxtTime>.
//
// Date formatting can cause hydration issues due to the difference locale on server and client.
// See: https://www.leopold.is/blog/nuxt-hydration-issues-and-dates/
export const formatDate = function (date) {
return new Date(date).toLocaleDateString("en-US", {
month: "short",
Expand Down