The Val Town Blog is now hosted directly on Val Town! The blog combines new posts written directly in this project with proxied content from our legacy blog.
The blog includes a comprehensive dark mode implementation:
prefers-color-scheme
)The dark mode uses carefully selected colors that maintain readability and accessibility while providing a comfortable viewing experience in low-light conditions.
/posts
directoryval-town-blog.pages.dev
)/posts
directory/index.ts
: Main entry point that sets up Hono routing and middleware/components/
: React components for rendering the blog
Layout.tsx
: Shared layout with header, footer, and stylingHomePage.tsx
: Renders the blog homepage with featured and recent postsBlogPost.tsx
: Renders individual blog postsHead.tsx
: Manages metadata, styles, and SEO/routes/
: Hono route handlers for different parts of the blog
home.ts
: Homepage routeblog.ts
: Individual blog post routesproxy.ts
: Proxy to the old blog for legacy contentrss.ts
: RSS feed generationfavicon.ts
& og-image.ts
: Asset routes/utils/
: Utility functions for post processing, caching, etc./posts/
: Markdown files for blog posts/styles/
: CSS stylingdata-theme
attribute switchingTo add a new blog post to the Val Town Blog:
/posts
directory with YAML frontmatter:---
title: My New Blog Post
description: A brief description of the post
pubDate: 2025-04-01T00:00:00.000Z
author: Your Name
---
Content of your blog post in markdown format...
/blog/[slug]
The blog supports GitHub Flavored Markdown (GFM) with:
The dark mode system uses several key components:
:root
for light mode and [data-theme="dark"]
for dark mode@media (prefers-color-scheme: dark)
to automatically apply dark mode for users who prefer itThemeToggle.tsx
) that renders the toggle button and includes the JavaScript for theme switchinglocalStorage
and restored on page loadThe implementation prevents flash of unstyled content (FOUC) by applying the theme immediately in an inline script before the page renders.
The blog includes a live reload feature that automatically refreshes the page when changes are made to the project. This works when viewing the blog on a .val.run
domain during development.
The blog implements efficient caching:
.val.run
are excluded from cachingThe blog is deployed directly on Val Town, with the production version available at blog.val.town.