How tangly1024/notionnext works
Project type and purpose
• This is a full-stack, static-rendered blog system built with Next.js that sources content from Notion via the Notion API.
• It runs on Vercel, uses serverless API routes for dynamic features (authentication, subscriptions, caching), and pre-renders pages (SSG/ISR).
Key architectural components
a. Client (Browser)
• Renders React pages, requests static assets (HTML/CSS/JS) from the CDN.
• Interacts with dynamic endpoints (search, subscribe, auth callbacks).
• Loads comment widgets and analytics scripts (Twikoo, Giscus, Google Analytics, etc.).
b. CDN / Static Hosting (Vercel Edge)
• Delivers pre-rendered pages, public assets (images, CSS, JS).
• Caches static HTML and pages (ISR).
c. Next.js Application
• Pages folder: UI routes (/, /category, /tag, /dashboard, etc.) with getStaticProps/Paths.
• API routes under pages/api:
– /auth (OAuth callback to Notion for sign-in)
– /cache (warm or purge caches)
– /subscribe, /user (user-related operations)
• Middleware: global request handling, redirects.
d. Content Source (Notion API)
• External service providing page blocks, metadata, categories, tags.
• Custom wrapper in lib/notion to fetch and transform data.
e. Caching Layer
• In-memory (lib/cache/memory_cache.js)
• Local file (lib/cache/local_file_cache.js) for SSG builds
• Redis (lib/cache/redis_cache.js) for shared or production caches
• Cache manager to orchestrate multi-tier cache.
f. Plugins & Utilities
• Conf directory: site configuration, theme selection, plugin toggles.
• lib/plugins: markdown enhancements (math via mhchem, word count), search indexing (Algolia).
• lib/utils: date formatting, slug generation, sitemap/rss.
g. Themes & UI Components
• Large library of independent React components (components/) for BI, animations, comment systems, etc.
• The “themes” folder: pre-built themes (next, medium, hexo…) exporting theme config, styles, and overrides.
External Services & Integrations
• Notion API (primary data store)
• GitHub Actions & Docker (CI/CD pipelines, image builds)
• Vercel (deployment & edge functions)
• Analytics (Ackee, Busuanzi, Gtag)
• Comment systems (Twikoo, Giscus, Gitalk, Utterances)
• Search (Algolia)