Skip to content
Sign inJoin waitlist

Using a headless CMS — Semono 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 Semono.

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 / getOtherServices, getPosts / getPost / getRelatedPosts, getCareers / getCareer, getLegalPages / getLegalPage, getTestimonials, getTeam and getClients. Mirror src/content/types.ts in the CMS:

Collection In the demo Fields
Service 6 slug, name, summary, image, highlight, overview (paragraphs), included (points), gallery (three images), deliver (four items: title, description), impact (four items: value, label)
Testimonial 7 slug, company, logo, quote, name, role, photo, summary, services (names), results (four items: value, label)
Post 12 slug, title, excerpt, image, category, date, body (rich text)
Career 5 slug, title, summary, location, type, overview, responsibilities (points), qualifications (points), offers (points)
LegalPage 2 slug, title, updated, body (rich text)
Member (the team) 6 slug, name, role, photo, linkedin
Client 10 name, logo
  • Relations. No collection refers to another by key; the links are by position and by value:
    • the testimonials are read by position: the first is the client story in “Why Choose” on Home, the third the quote on About, the fourth the quote beside the closing line of “Our Services” on Home, and the first eight are the grid of cards on Home and Services (each card’s look follows its position); the Testimonial page lists them all. Keep the order in the CMS, and at least one testimonial: Home and About can’t be built without;
    • a testimonial’s services are names, not references. The Contact form’s “Service Required” choices are typed in src/content/pages/contact.ts, not read from the services;
    • related posts share a category: getRelatedPosts returns up to three other posts with the same category, in list order, and the section is left out when there are none. The demo uses Operational, Leadership and Business, so a choice field in the CMS works;
    • getOtherServices returns the first four other services, in list order.
  • 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 shows the first four services (services.limit in src/content/pages/home.ts), up to eight testimonials, every client and the first three posts; About the first three team members; the Services page numbers its rows 01, 02, … by position. The Services, Testimonial and Blog pages load four items at a time (six on desktop for the Blog).
  • Counts. A service needs three gallery images, four deliver items and four impact items; a testimonial four results (Editing the content).
  • getOtherServices and getRelatedPosts filter the full list, so they keep working when getServices and getPosts fetch from the CMS. The footer’s Services column and the sitemap read the same functions.
  • The footer’s legal links (footer.legalLinks in src/content/site.ts) are typed, not read from the legal pages.

Post bodies and legal texts are blocks, not HTML:

{ type: "heading", text: "…" } // one heading size
{ type: "paragraph", text: "…" } // *italic* between asterisks, "\n" for a line break
{ type: "list", ordered?: true, items: [[ …blocks ], [ …blocks ]] } // each item is a list of blocks

There is no bold and there are no links inside the text. The demo’s posts use headings, paragraphs and bulleted lists; the legal texts add one list to headings and paragraphs. Convert your CMS’s rich text to these blocks in your mapping function, italics as *…* (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 (the wide photo, the row’s photo and the share image) 1800 × 1013
A service’s gallery 600 px wide: 600 × 900 for the tall one, 600 × 400 for the others
A post’s image (the card and the wide cover) 1800 × 1200
A team member’s photo 800 × 1200 (2 : 3, cropped from the top)
A testimonial’s photo 160 × 160 (shown round, 42 px)
Client and company logos SVG, shown 24 px tall (20 on phones) in the ticker and about 15 px tall on the cards

Photos go through next/image, which needs the CMS’s host in images.remotePatterns of next.config.ts (Images). The logos are unoptimized SVG files, so they load from any address. For logos in public/, src/lib/image-size.ts reads their size when the site builds; a logo from another address gets a default box until the file loads (100 × 24 for a client, 90 × 15 for a company logo; see src/lib/to-ui.ts) and then takes its own proportions.