Skip to content
Sign inJoin waitlist

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

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: getProjects / getProject and getServices / getService / getOtherServices. Mirror src/content/types.ts in the CMS:

Collection In the demo Fields
Project (portfolio.ts) 16 slug, title, summary, date, service (a service’s slug), details (rich text), image, gallery (images)
Service (services.ts) 4 slug, name, summary, price (text), image, content (rich text), perfectFor (up to four lines), included (up to five lines)

Every image is { src, alt }.

  • Reference. A project points to its service by the service’s slug (service). A reference field in the CMS works: map it to the slug in your mapping function. The project page looks the service up with getService to show its name, the Portfolio tabs filter on it, and “Related Projects” are the other projects with the same service, up to three, in list order. A project without a matching service shows under “All” only.
  • Order. Lists keep the order they arrive in; nothing is sorted by date. The CMS order of the projects is newest first in the demo, so give the CMS a sort field or sort by date in your query. Home shows the first six projects (projects.count in src/content/pages/home.ts) and every service; Portfolio loads four projects at a time; the Portfolio tabs follow the order of the services; getOtherServices returns the first three other services, in list order.
  • Lines. perfectFor and included are lists of plain lines, numbered 01, 02, … on the service page; an empty line leaves its row out. A CMS list of text fields, or four and five single fields as in the original design, both map to them.
  • getOtherServices, the related projects and the Portfolio tabs filter the full lists, so they keep working when getProjects and getServices fetch from the CMS. The sitemap reads the same functions.
  • The testimonials, the “See what I do” gallery, the awards and the questions are page copy in src/content/pages/, not collections.

A project’s details and a service’s content are paragraphs, not HTML:

{ type: "paragraph", text: "…" } // **bold** between double asterisks, *italic* between single ones, "\n" for a line break

There are no headings, lists or links in the demo’s texts. Each service’s content starts with a line in italics. Convert your CMS’s rich text to these blocks in your mapping function, bold as **…** and italics as *…* (how). The RichText component can also draw headings and lists: widen RichTextBlock in src/content/types.ts to its type to use them.

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 card at 565 : 600 and the page’s photo, a portrait frame on the left) 1440 × 1440
A project’s gallery (shown at 0.74 : 1, one under the other) 1440 px wide
A service’s image (the page’s photo, a portrait frame on the left, and the row’s thumbnail, 200 × 145 on desktop) 1200 × 800 or larger; a portrait photo fits the page’s frame best

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.