Technical Breakdown: Website Architecture
Framework & Technology Stack
Next.js with React
- Next.js as the full-stack React framework
- Turbopack for local development (
next dev --turbopack) - React Strict Mode enabled for development warnings
Directory Structure
demo-blog/
├── src/
│ ├── pages/ # Next.js Pages Router
│ │ ├── _app.js # Global app wrapper
│ │ ├── _document.js # HTML document structure
│ │ ├── index.js # Home page (blog listing)
│ │ └── posts/
│ │ └── [id].js # Dynamic post routes
│ ├── lib/
│ │ └── posts.js # Data fetching utilities
│ └── styles/
│ └── globals.css # Global CSS styles
├── posts/ # Markdown blog content
├── public/ # Static assets
├── package.json
├── next.config.mjs
└── jsconfig.json
Routing Architecture
This project uses the Next.js Pages Router.
| File | URL | Purpose |
| ------------------------- | ------------ | --------------------------- |
| src/pages/index.js | / | Home page with post listing |
| src/pages/posts/[id].js | /posts/:id | Individual post pages |
The [id] parameter maps to markdown filenames (e.g., 1.md becomes /posts/1).
Data Flow
Content Source
Blog posts are stored as Markdown files with YAML front matter in the /posts/ directory:
---
title: "Post Title"
date: "2025-12-17"
description: "Brief description"
---
Content here...
Processing Pipeline (src/lib/posts.js)
Three core functions handle data:
getAllPosts()- Reads all.mdfiles, parses front matter withgray-matter, sorts by date descendinggetPostById(id)- Fetches a single post, converts markdown to HTML usingremark+remark-htmlgetAllPostIds()- Returns all post IDs for static path generation
Build-Time Generation
- Static Generation (SSG) - All pages pre-rendered at build time
getStaticProps()fetches data during buildgetStaticPaths()pre-generates all dynamic routes- Result: Fully static site, no server computation needed
Key Dependencies
| Package | Purpose |
| ------------- | ------------------------------------- |
| gray-matter | Parse YAML front matter from markdown |
| remark | Markdown processing engine |
| remark-html | Convert markdown AST to HTML |
| date-fns | Date formatting (MM/dd/yyyy) |
Component Structure
Global Wrappers
_app.js- Wraps all pages, imports global CSS_document.js- Sets HTML structure withlang="en"
Page Components
index.js- Maps through posts, renders list with linksposts/[id].js- Renders full post HTML viadangerouslySetInnerHTML
Architectural Decisions
- Static Site Generation - Optimal performance, all content pre-rendered
- File-based CMS - Markdown files are version-controlled with git
- Pages Router - Simpler and stable for this use case
- Minimal Dependencies - No UI libraries, no CSS frameworks
- Plain CSS - Full design control, smaller bundle size
Deployment
- Configured for Vercel deployment
- Compatible with any static hosting (Netlify, GitHub Pages, etc.)
- New posts require rebuild and redeploy