Using a headless CMS — Brickfolio 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 Brickfolio.
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: getProjects / getProject / getMoreProjects, getServices and
getPosts / getPost / getMorePosts. Mirror src/content/types.ts in the CMS:
| Collection | In the demo | Fields |
|---|---|---|
Project (projects.ts) |
6 | slug, title, service (text), date, client, summary, cover, description (rich text), highlights (rich text), gallery (three images, each with visible) |
Service (services.ts) |
4 | slug, title, description, price (text, “$3,000”), href (“More Details”), images (four images, each with visible) |
Post (posts.ts) |
12 | slug, title, category (text), date, image, body (rich text) |
An image is an object, { src, alt } (with visible: true | false in a gallery or a service): the path or address and
its description. Dates are ISO dates ("2024-07-08"); a project shows only its month and year.
- No references. A project’s
serviceand a post’scategoryare plain text, not links to other collections. “More Posts” matches the category text exactly, so keep one spelling per category (a select field in the CMS). - Order. Projects and services keep the order they arrive in: give them an order field in the CMS and sort by it in
your query.
getPosts()sorts the posts bydate, newest first, whatever order the CMS returns. Home shows four projects and four posts, then four more per click (pageSizeinsrc/content/pages/home.ts); “More Projects” lists the first three other projects, “More Posts” the three newest other posts of the category (countinproject.tsandpost.ts). - Services have no page. They appear on Home only, so
slugis just an identifier. Testimonials, experience, client logos and the questions are lists insrc/content/pages/home.ts, not collections: move them to the CMS as a settings document if editors should change them. - Gallery images. A project has exactly three: the first two side by side, the third full width;
visible: falsehides one. A service has four, shown in two moving columns. Model them as fixed fields (as the original design does) or as a list of up to three or four. - Every project and post has a page.
/project/<slug>and/blog/<slug>are built from the collections, and the sitemap reads the same functions.
Rich text
Section titled “Rich text”A project’s description and highlights and a post’s body are blocks, not HTML:
{ type: "paragraph", text: "…" } // **bold** and `code` inline{ type: "heading", level: 3, text: "…" } // levels 2–6 share one style{ type: "list", ordered: false, items: ["…", "…"] } // an item is a string …{ type: "list", ordered: true, items: [{ text: "…", ordered: false, items: ["…"] }] } // … a string with a nested list …{ type: "list", ordered: true, items: [{ text: "…", blocks: [/* paragraphs and lists */] }] } // … or a string followed by blocksThe demo uses paragraphs, headings of level 3, bulleted and numbered lists, items that hold more paragraphs and lists,
bold and inline code (three posts). There are no italics, links or images inside the text. Convert your CMS’s rich text
to these blocks in your mapping function, bold as **…** and code as `…`
(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 cover (3 : 2 on its page, up to 1000 px wide; 380 px tall on the cards) |
1600 × 1066 or larger |
A project’s gallery (3 : 2; the first two half the column, the third the full 1000 px) |
1000 wide (first two), 1600 wide (third) |
A post’s image (3 : 2 on its page; 250 px tall on the cards) |
1600 wide |
A service’s images (100 × 150 tiles) |
300 wide (200 to 375 tall) |
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.