How asmattic/matthewoldfield-com works
Project Type and Purpose
• This is a full-stack static+dynamic Next.js application serving as a personal portfolio and blog.
• It uses file-based content (MDX), Tailwind CSS for styling, Contentlayer for content ingestion, and serverless API routes for newsletter and authentication integrations.
File-Structure Analysis
• pages/ : Next.js page routes (static pages, MDX-based blog, API endpoints under pages/api).
• layouts/ : page templates (AuthorLayout, PostLayout, ListLayout, etc.).
• data/ : site metadata, authors, blog posts, project data, nav links.
• lib/ & scripts/ : content-processing utilities (Remark plugins, contentlayer config, RSS & sitemap generators).
• public/static/ : static assets (images, favicons, downloads).
• next.config.js, middleware.ts, Contentlayer config: build and runtime configuration.
Key Technologies & Patterns
• Next.js SSG/SSR and Incremental Static Regeneration for page rendering.
• Contentlayer to transform MDX content into JSON data at build time.
• File-based routing and API routes (newsletter subscribe endpoints, auth via NextAuth).
• Tailwind CSS/PostCSS for styling, PrismCSS for code blocks.
• Serverless functions (Vercel) for dynamic features.
• External integrations: Google Analytics, Disqus (comments), Buttondown/ConvertKit/Mailchimp (newsletter), NextAuth (auth).
Main Components
a. Browser / Client
• Renders HTML/CSS/JS bundle, initiates API calls, executes GA scripts.
b. CDN / Static Hosting (Vercel)
• Serves static assets (JS bundles, CSS, images, fonts) and pre-rendered HTML.
c. Next.js Application
• SSG Build Pipeline:
• Contentlayer reads MDX & data files → generates GraphQL-style data nodes
• Next.js build generates static pages (HTML + JSON)
• Scripts generate RSS & sitemap
• Runtime Serverless Functions:
• pages/api/auth/[...nextauth] → NextAuth handlers
• pages/api/buttondown.js, convertkit.js, mailchimp.js → newsletter endpoints
• Middleware.ts for any edge logic/CSP enforcement.
d. Data Layer
• Local file system: MDX blog posts, JSON/JS data files (siteMetadata, projectsData, authors).
• contentlayer.config.ts orchestrates file ingestion.
e. Styling Pipeline
• tailwind.config.js + PostCSS + css/tailwind.css → compiled CSS
• css/prism.css → code block styling
f. External Services
• Google Analytics (analytics/GoogleAnalytics.tsx)
• Disqus (comments/Disqus.tsx)
• Newsletter providers: Buttondown, ConvertKit, Mailchimp
• Authentication providers via NextAuth
Relationships & Data Flows
• At build time: File system → Contentlayer → Next.js build → Static HTML + JSON → CDN
• At runtime (Client):
• Client requests page from CDN → HTML + hydration JS → React SPA
• Client fires GA events → Google Analytics
• Client submits newsletter form → Next.js API route → external newsletter API → confirmation
• Client loads Disqus script → Disqus comment threads
• Client may trigger NextAuth flows → external auth provider → NextAuth API route
• All static assets (CSS, images) fetched from CDN/public/static.
Architectural Patterns & Principles
• Jamstack hybrid: static generation + dynamic serverless endpoints
• Component-driven UI (React), layout composability
• Clear separation: presentation (components/layouts), content (data/MDX), logic (lib, scripts, API)
• Convention-over-configuration: Next.js file routing, Contentlayer ingestion
Final Recommendations
• Above components and flows without over-splitting trivial files.
• Custom middleware or special CSP considerations from next.config.js & middleware.ts.
• Keep it high-level yet detailed enough to show static vs dynamic boundaries and external integrations.