Using a headless CMS — Cerette 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 Cerette.
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, the footer and the sitemap read them through src/lib/content.ts: getProjects / getProject /
getOtherProjects / getProjectServices, getServices / getService, getTestimonials, getTeam, getPosts /
getPost / getRelatedPosts and getLegalPages / getLegalPage. Mirror src/content/types.ts in the CMS:
| Collection | In the demo | Fields |
|---|---|---|
Project (projects.ts) |
6 | slug, title, summary, category (any text), image, year, location, duration, area, services (service slugs), overview, brief, scope, images (exactly four), result, gallery (images), resultImage |
Service (services.ts) |
6 | slug, name, summary, image, about, included (text, items: each title, text) |
Testimonial (testimonials.ts) |
6 | slug, name, role, photo, year, rating (a number such as 4.9), quote |
TeamMember (team.ts) |
12 | slug, name, role, photo, summary |
Post (posts.ts) |
12 | slug, title, category (Architecture, Construction or Interior), date, excerpt, image, content (rich text) |
LegalPage (legal.ts) |
2 | slug, title, date, content (rich text) |
Every image is { src, alt }.
- References. A project names its services by their
slugs (services). A reference field in the CMS works: map it to the slugs in your mapping function.getProjectServiceslooks them up in the full list of services, in the project’s order, and leaves out a slug that matches none. - Project photos.
imagesis exactly four photos: the first and the fourth are shown tall, the second and the third wide. Four single image fields map to it most simply.gallerytakes any number (three in the demo). - Deliverables. A service’s
included.itemsis a list of a title and a line; an empty line shows the title alone. A repeatable group in the CMS maps to it. - Order. Projects, services, testimonials and the team keep the order they arrive in, so give the CMS a sort field.
Posts are sorted by
date, newest first, ingetPosts. Home shows the first six projects, every service (numbered 01, 02 … in that order), every testimonial and the three newest posts; Projects every project and testimonial; About every team member (six cards at first on tablets and phones); a project page the first three other projects; a post up to three more of its category; Blog six posts at a time on desktops, four on tablets and phones. - Pages of their own: projects, services, posts and legal pages; testimonials and the team have none (their
slugis an id). getOtherProjects,getProjectServicesandgetRelatedPostsfilter the full lists, so they keep working when theget…functions fetch from the CMS. The footer (services, legal pages) and the sitemap read the same functions.- The numbers, the awards, the founder’s quote, “Why Cerette”, the call to action and the forms are page copy in
src/content/pages/, not collections.
Rich text
Section titled “Rich text”A post’s and a legal page’s content is blocks, not HTML:
{ type: "paragraph", text: "…" } // **bold**, *italic*, [label](address), "\n" for a line break{ type: "heading", level: 3, text: "…" } // every level looks the same (Heading 3){ type: "list", ordered: false, items: [[ …blocks ], [ …blocks ]] } // each item is a list of blocks{ type: "quote", text: "…" }The demo’s posts and legal pages use headings, paragraphs and bulleted lists. Convert your CMS’s rich text to these
blocks in your mapping function, bold as **…**, italics as *…* and links as label
(how).
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 project’s image (the full-window cover, the cards) |
2400 px wide |
A project’s first and fourth images (tall, 2 : 3) |
456 px wide |
A project’s second and third images, its gallery and resultImage (3 : 2) |
1724, 1090 and 2280 px wide |
A service’s image (3 : 2 on its page, 1.65 : 1 on the cards) |
2280 px wide |
A post’s image (1.9 : 1 on the card, 3 : 2 on the post) |
2280 px wide |
A testimonial’s photo (round, 38 px) |
152 × 152 |
A team member’s photo (0.74 : 1) |
798 px wide |
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 layout
needs no width and height from the CMS.