How netlify-templates/content-ops-starter works
Project Type and Purpose
• This is a Next.js–based static site starter, optimized for Netlify’s Visual Editor and Git Content Source workflow.
• It includes an Algolia search integration and a small serverless API for re-indexing.
File Structure
• content/ – your markdown and JSON content files (data + pages).
• sources/local/ – TypeScript models and JSON presets defining your content schema.
• src/pages/ – Next.js page routes including a serverless function (api/reindex.js).
• src/components/ – React components organized into atoms, blocks, sections, layouts, etc.
• utils/ – data‐loading, indexing, and static props resolvers.
• Configs: netlify.toml, next.config.js, stackbit.config.ts for Netlify & Stackbit integration; tsconfig.json, tailwind.config.js, postcss.config.js for build toolchains.
Dig into the README for Clues
• Netlify Visual Editor CLI hooks into your content folder via the Stackbit config.
• Algolia search requires environment variables and uses the /api/reindex endpoint plus indexer utilities in utils/indexer.
Main Components & Their Roles
a. Developer Environment
– Git repository (hosted on GitHub)
– Local dev: npm run dev (Next.js) + stackbit dev (Visual Editor)
b. Build & Deployment
– Netlify CI/CD (netlify.toml)
– Next.js static site builder (SSG)
– Stackbit/Netlify Visual Editor (real-time WYSIWYG)
c. Runtime Delivery
– Netlify CDN (serves static HTML/CSS/JS)
– Serverless Function: /api/reindex (Next.js API route)
d. Data & Search
– Local content files (content/)
– TypeScript data models (sources/local/models)
– Presets (sources/local/presets)
– Algolia Search Service (external)
– Indexer utility (utils/indexer/*.js)
Relationships & Data-Flows
• On code push → GitHub → Netlify build
→ Next.js reads content & models → generates static HTML/JS → deploy to CDN
• Dev & Content Editing:
Local dev server + Stackbit CLI ↔ content files ↔ Visual Editor UI
• Search Indexing:
Trigger via Netlify rebuild hook or manual call to /api/reindex → indexer reads content → pushes to Algolia → website’s SearchBlock component queries Algolia over REST
Architectural Patterns & Design Principles
• Jamstack: Static site generation + CDN delivery
• Component-driven UI: Atoms → Blocks → Sections → Layouts
• Content as Data: Markdown/JSON files + typed models → ContentOps
• Serverless: thin API layer for background tasks (reindexing)
• CI/CD + GitOps: every change goes through Git and Netlify builds