Skip to content
Sign inJoin waitlist

Headless CMS — Compose Digi 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 Compose Digi.

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.

Pages read them through src/lib/content.ts: getServices / getService, getProjects / getProject, getPosts / getPost and getCareers / getCareer. Mirror src/content/types.ts in the CMS:

Collection In the demo Fields
Service (services.ts) 8 slug, name, summary, image, offer (rich text), benefits (rich text), weekly and monthly (each a price as text and features, lines: four in the demo)
Project (projects.ts) 8 slug, title, company, year (text), summary, thumbnail, services (references to services, by slug), testimonial (name, role, photo, quote), overview (rich text), mainImage, process (rich text), images (exactly two images), outcome (rich text), finalImage
Post (posts.ts) 12 slug, title, excerpt, image, category (text), date, body (rich text)
Career (careers.ts) 12 slug, title, type (text: “Remote”, “Full Time”, “Part Time”, “Freelance”), summary, responsibilities, requirements, benefits, apply (four rich texts)

Images are objects with their description, { src, alt }: src a path or an address. Dates are ISO dates ("2024-06-25").

  • Projects → services. A project’s services is a list of service slugs: the tags above its title link to those services’ pages, and Home’s strip shows the first one’s name. Model it as a reference to the services, mapped to their slugs; a slug that matches no service is skipped. The project’s client quote is a group of fields on the project, not a collection of its own.
  • Order. Lists keep the order they arrive in; nothing is sorted by date. Posts are newest first in the demo (Blog, Home, Prev / Next, “More Blog”), so sort by date descending in your query; services, projects and openings follow the order you give them, so add an order field to the CMS. Home shows the first six services (services.count in src/content/pages/home.ts), the first four projects in its strip and five from the fourth on in its list (projects.tickerCount, listOffset, listCount) and the first three posts (blog.count); About the first three openings (positions.count in about.ts); Services the client quotes of the first three projects (testimonials.count in services.ts); the footer the first eight service names.
  • Services in the form and the footer. The contact form’s “Services” checkboxes are the names of every service, and the footer’s moving rows the first eight, so a service added in the CMS shows in both after the next build. The root layout (src/app/layout.tsx) reads the services for the footer, so every page depends on that query.
  • Pages of their own. Every item gets a page (/services/<slug>, /projects/<slug>, /blog/<slug>, /careers/<slug>), and the sitemap reads the same functions. A project’s slug may hold accented letters (the page decodes it).
  • The team, the figures, the client logos, the About video, the process chart and the founder’s quote are page copy in src/content/pages/, not collections.

A service’s offer and benefits, a project’s overview, process and outcome, a post’s body and an opening’s four texts are blocks, not HTML:

{ type: "heading", level: 3, text: "…" } // the level picks the text style (3 in the demo's posts)
{ type: "paragraph", text: "…" } // **bold**, *italic*, [label](https://…) for a link, "\n" for a line break
{ type: "list", ordered: false, items: [[{ type: "paragraph", text: "…" }], …] } // each item is its own list of blocks

The demo’s texts use headings, paragraphs, bulleted and numbered lists (a project’s Process), bold lead-ins and an e-mail link ([careers@example.com](mailto:careers@example.com) in every opening). There are no images inside the text. Convert your CMS’s rich text to these blocks in your mapping function, bold as **…**, italics as *…* and links as label (how).

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 (353 : 420 on cards; 1200 : 680 across the full width of its page) 2200 × 1460 or larger
A project’s thumbnail (the cards, the Home strip, and the 1120 × 635 cover of its page) 2000 × 1333 or larger
A project’s mainImage and finalImage (3 : 2, full width) 2000 × 1333 or larger
A project’s two images (2 : 1, up to 75 % of the width) 1200 × 600 or larger
A testimonial’s photo (round, 72 px) 150 × 150
A post’s image (353 : 420 on cards, 3 : 2 on its page) 2000 × 1333 or larger

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.