Using a headless CMS — KorDent Next.js
Connecting a headless CMS works the same for every Next.js template sold on Framebrick, so this page lists only what is specific to KorDent.
The approach, rich text, images, keeping pages fresh, and step-by-step guides for Sanity, Payload, Strapi and Directus are in Use a headless CMS with a Next.js template.
Collections
Section titled “Collections”Pages read them through src/lib/content.ts: getServices / getService, getCategories, getDoctors /
getDoctor, getPosts / getPost / getOtherPosts, getLegalPages / getLegalPage, getOutcomes,
getTestimonials, getFacts, getFeatures and getAdvantages. Mirror src/content/types.ts in the CMS:
| Collection | In the demo | Fields |
|---|---|---|
Service |
14 | slug, title, category (a Category slug), summary, description, price, duration, anesthetic, urgent (yes/no), icon (one of 14 names), label (text or empty; not shown), image, about, included, process (rich text), doctors (Doctor slugs) |
Category (departments) |
4 | slug, name |
Doctor (dentists) |
4 | slug, name, specialty, bio, image, hours, education, experience, languages (lists of text) |
Post |
6 | slug, title, excerpt, category (text), date, readTime, image, body (rich text) |
LegalPage |
3 | slug, title, updated, body (rich text) |
Outcome |
4 | slug, category, tab, title, summary, quality (list of text), timeline, services (Service slugs), images (four) |
Testimonial (reviews) |
4 | slug, name, date, service (a Service slug), photo, rating (1–5), title, quote |
Fact |
4 | text |
Feature |
8 | title, text, icon (one of 8 names) |
Advantage |
3 | title, text |
Every image is { src, alt }.
- Relations. They are by slug, and the mapping in
src/lib/to-ui.tsresolves them:- a service’s
categoryputs it under a department tab; a service whose category matches noCategoryshows under “All” only; - a service’s
doctorsare the dentists its booking form offers (in the order of the dentists’ list); a slug with no dentist is skipped; - an outcome’s
servicesand a review’sserviceare shown as the services’ titles; a slug with no service is shown as the slug, so a reference field that returns slugs is the simplest mapping; - the review form’s treatments and the booking form’s treatments and dentists are the full lists of services and dentists.
- a service’s
- Order. Lists keep the order they arrive in, not by date. The demo’s posts are newest first; give the CMS a sort
field. Home’s services grid shows the first six that match the chosen tab and search (
services.limitinsrc/content/pages/home.ts), the Services page fourteen (list.limit, every service of the demo: raise it if you add more), a service page the first six others; Home shows the first three posts, and a post the first three others. The outcome cards are numbered 01, 02, … by position, and the facts row gives each position its own icon and tint. - Counts. An outcome needs four
images; the facts row is laid out for four facts (Editing the content). getOtherPostsandgetServicefilter the full list, so they keep working whengetServicesandgetPostsfetch from the CMS. The sitemap reads the same functions.- The footer’s Dental Services column and legal links (
footer.services,footer.legalLinksinsrc/content/site.ts) are typed, not read from the collections.
Rich text
Section titled “Rich text”A service’s three texts, post bodies and legal texts are blocks, not HTML:
{ type: "heading", level: 2 | 3 | 4 | 5 | 6, text: "…" } // the text style of its level{ type: "paragraph", text: "…" } // **bold**, [text](href), "\n" for a line break{ type: "list", ordered: boolean, items: [[ …blocks ], [ …blocks ]] } // each item is a list of blocks{ type: "table", rows: [[ { header: true, text: "…" }, … ], …] } // header cells are thThe demo’s service texts start with a level-6 heading and use paragraphs with bold runs (one service adds level-2 and
level-3 headings); the posts use level-3 headings (the post page writes the highest one as an h2, its look unchanged:
RichText topLevel={2}), paragraphs, bulleted lists and, in three posts, a table; the legal
texts use level-2 and level-3 headings, paragraphs and lists. There is no italic. Convert your CMS’s rich text to these
blocks in your mapping function, bold as **…** and links as text
(how). Many rich-text editors have no table by default: check that
yours can hold one (or add a table plugin) before you move the posts that carry one, and map it to rows of cells.
Images
Section titled “Images”Every photo sits in a frame and is cropped to fill it, so a photo of other proportions works; upload images at least as large as the layout uses:
| Image | Size |
|---|---|
A service’s image (the wide photo and the share image) |
1920 × 1280 (3 : 2) |
A post’s image (the card and the wide cover) |
1920 × 1280 (3 : 2) |
A dentist’s image |
600 × 750 |
An outcome’s images |
600 × 400 each |
A review’s photo |
160 × 160 (shown round) |
Photos go through next/image, which needs the CMS’s host in images.remotePatterns of next.config.ts
(Images). Every photo fills a frame of its own shape, so the
components need no width or height from the CMS.