How yyycc/whatsoever works
Project Type and Purpose
• This is a Gatsby‐based static site generator (SSG) built with TypeScript.
• Its primary purpose is to render a blog/documentation site from MDX content and React components, producing fully static HTML/CSS/JS at build time and hydrating it in the browser.
High‐Level Architecture Components
a. Source Content Layer
• MDX/Markdown files under blog/ and src/pages/
• Static assets in src/images/ and stylesheets (.scss, css)
b. Plugin & Transformer Layer
• gatsby-config.ts: defines plugins (e.g. gatsby-source-filesystem, MDX plugin, remark plugins) and site metadata
• Custom plugin in plugins/gatsby-remark-code-buttons for adding code‐copy buttons
• Transformers: gatsby-transformer-remark/gatsby-plugin-mdx that turn MDX into GraphQL nodes
c. Data Layer (GraphQL)
• Gatsby’s in‐memory GraphQL schema generated at build time from filesystem and plugin nodes
• Queries in page templates to pull frontmatter, HTML AST, image data, etc.
d. Page Generation Layer
• gatsby-node.ts: uses Node APIs (onCreateNode, createPages) to build pages programmatically (e.g. dynamic blog‐post pages using {mdx.frontmatter__slug}.tsx)
• Templates under src/pages and shared components under src/components produce static HTML
e. Client Application Layer
• React components (header, footer, blog-list, common-*) compiled into JS bundles
• Hydration/runtime hooks in gatsby-browser.ts (e.g. wrapRootElement)
f. Server‐Side Rendering & Deployment
• gatsby-ssr.ts for injecting <head> tags, styles
• Final output: static /public folder with HTML, JS, CSS ready for any static host (Gatsby Cloud, Netlify, etc.)
Relationships & Data Flow
1. Filesystem → Gatsby Source Plugins
2. Source Plugins → Transformer Plugins
• Transformer plugins convert raw files into GraphQL nodes.
3. Transformer Plugins → GraphQL Schema
• All nodes are stitched into Gatsby’s schema.
4. GraphQL Queries in Page Templates
• Page templates/components query data at build time.
5. Page Generation (createPages)
• Gatsby Node API uses query results to generate static HTML pages.
6. SSR & Asset Injection
• gatsby-ssr.ts injects global CSS, metadata.
7. Client Hydration
• gatsby-browser.ts sets up React context/hooks for interactivity.
8. Deployment
• Final /public folder served as static site.
Architectural Patterns & Design Principles
• Plugin Architecture: clear extension points via Gatsby Node APIs
• Component-Based UI: React + modular SCSS for style encapsulation
• Static Site Generation: pre-render everything at build time for performance
• GraphQL Data Layer: decouples content from presentation