• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
arfan

arfan

min-md-blog

Unlisted
Like
min-md-blog
Home
Code
10
posts
1
App.tsx
Layout.tsx
Post.tsx
README.md
components.tsx
config.ts
H
main.tsx
routes.ts
utils.ts
Branches
6
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
6/7/2025
Viewing readonly version of main branch: v45
View latest version
README.md

Blog Application

A clean, modern blog built with React, DaisyUI, and Val Town. Features theme switching, math rendering, code highlighting, and HTML-in-markdown support.

Features

  • Modern UI: DaisyUI components with 30+ themes
  • Clickable Post Cards: Entire cards are clickable for better UX
  • Theme Persistence: Automatic theme saving via localStorage
  • HTML in Markdown: Full HTML support within markdown files
  • Math & Code: KaTeX math rendering and syntax highlighting
  • Responsive Design: Mobile-friendly layout

Project Structure

├── main.tsx              # HTTP entry point
├── routes.ts             # Request routing and page rendering
├── config.ts             # Shared configuration and types
├── utils.ts              # Utility functions
├── components.tsx        # Reusable UI components
├── App.tsx               # Homepage component
├── Post.tsx              # Post display component
├── Layout.tsx            # HTML layout with styles/scripts
├── posts/                # Markdown blog posts
└── README.md

Architecture

Design Principles Applied

  • KISS: Simple, focused components with single responsibilities
  • DRY: Shared configuration, utilities, and reusable components
  • SoC: Clear separation between routing, UI, and utilities
  • YAGNI: Removed unused features (font sizing, static files, etc.)

Key Components

config.ts - Centralized configuration

  • Blog settings (title, description, preview length)
  • Theme definitions and types
  • Shared interfaces

utils.ts - Pure utility functions

  • Content preview generation
  • Post title extraction
  • HTML response creation

components.tsx - Reusable UI components

  • ThemeSelector: DaisyUI theme dropdown
  • BlogHeader: Title and theme selector
  • Breadcrumbs: Navigation for post pages

Post.tsx - Unified post component

  • Handles both preview and full content display
  • Single component with isPreview flag

routes.ts - Clean request handling

  • Separated data loading from rendering
  • Consistent error handling
  • Reusable page rendering function

Usage

  1. Add .md files to posts/ directory
  2. Click post cards to view full content
  3. Use theme selector to change appearance
  4. Include HTML in markdown for rich content

Code Quality

  • Reduced LOC: ~40% reduction from original codebase
  • No Duplication: Theme lists, headers, and utilities centralized
  • Clear Naming: Descriptive function and variable names
  • Focused Functions: Each function has a single, clear purpose
  • Type Safety: Full TypeScript interfaces and types

Refactoring Results

Before vs After

  • Files: 6 → 9 (better separation of concerns)
  • Lines of Code: ~400 → ~240 (40% reduction)
  • Duplicated Code: Multiple theme lists → Single source of truth
  • Component Complexity: Mixed concerns → Single responsibilities
  • Maintainability: Monolithic → Modular architecture

Eliminated

  • ❌ Unused showFullPosts logic
  • ❌ Unused addFontSize function
  • ❌ Redundant static file handling
  • ❌ Duplicate theme selector code
  • ❌ Mixed UI/routing concerns
  • ❌ Verbose inline styles and scripts

Improved

  • ✅ Centralized configuration
  • ✅ Reusable components
  • ✅ Clear separation of concerns
  • ✅ Consistent naming conventions
  • ✅ Simplified component logic
  • ✅ Better error handling
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.