Skip to content
Sign inJoin waitlist

Using a headless CMS — KorDent Astro

Connecting a headless CMS works the same for every Astro template sold on Framebrick, so this page lists only what is specific to KorDent.

Loaders and schemas, rich text, images, rebuilding on publish, and step-by-step guides for Sanity, Payload, Strapi and Directus are in Use a headless CMS with an Astro template.

src/content.config.ts defines them, src/content/schemas.ts checks every entry when the site builds, and pages read them through src/lib/content.ts: getServices / getService, getCategories, getDoctors / getDoctor, getPosts / getPost / getOtherPosts, getLegalPages / getLegalPage, getOutcomes, getTestimonials, getFacts, getFeatures and getAdvantages. To fetch a collection from a CMS, replace its loader and keep its schema, or rewrite those functions; pages, sections and components stay unchanged. Mirror the schemas in the CMS:

Collection In the demo Fields
services 14 slug, title, category (a categories slug), summary, description, price, duration, anesthetic, urgent (yes/no), icon (one of 14 names), label (text or empty; not shown), image, about, included, process (rich text), doctors (doctors slugs)
categories (departments) 4 slug, name
doctors (dentists) 4 slug, name, specialty, bio, image, hours, education, experience, languages (lists of text)
posts 6 slug, title, excerpt, category (text), date, readTime, image, body (rich text)
legal 3 slug, title, updated, body (rich text)
outcomes 4 slug, category, tab, title, summary, quality (list of text), timeline, services (services slugs), images (four)
testimonials (reviews) 4 slug, name, date, service (a services slug), photo, rating (1–5), title, quote
facts 4 text
features 8 title, text, icon (one of 8 names)
advantages 3 title, text

Every image is { src, alt }.

  • Relations. They are by slug, and the mapping in src/lib/to-ui.ts resolves them:
    • a service’s category puts it under a department tab; a service whose category matches no department shows under “All” only;
    • a service’s doctors are the dentists its booking form offers (in the order of the dentists’ list); a slug with no dentist is skipped;
    • an outcome’s services and a review’s service are shown as the services’ titles; a slug with no service is shown as the slug, so a reference field that returns slugs is the simplest mapping;
    • the review form’s treatments and the booking form’s treatments and dentists are the full lists of services and dentists.
  • Order. Lists keep the order they arrive in, not by date: return entries in the CMS’s order with their position (src/lib/content.ts sorts by it), and give the CMS a sort field. The demo’s posts are newest first. Home’s services grid shows the first six that match the chosen tab and search (services.limit in src/content/pages/home.json), the Services page fourteen (list.limit, every service of the demo: raise it if you add more), a service page the first six others; Home shows the first three posts, and a post the first three others. The outcome cards are numbered 01, 02, … by position, and the facts row gives each position its own icon and tint.
  • Ids. Keep each entry’s id equal to its slug, as src/content.config.ts does (facts, features and advantages, which have none, use their position): getService(slug), getDoctor(slug), getPost(slug) and getLegalPage(slug) look entries up by it.
  • Counts. An outcome needs four images; the facts row is laid out for four facts (Editing the content).
  • Dates. A post’s date, a review’s date and a legal page’s updated are ISO dates ("2026-03-12").
  • getOtherPosts filters the full list, so it keeps working when the loaders fetch from the CMS. The sitemap reads the same functions.
  • The footer’s Dental Services column and legal links (footer.services, footer.legalLinks in src/content/site.json) are typed, not read from the collections.

A service’s three texts, post bodies and legal texts are blocks, not HTML:

{ type: "heading", level: 2 | 3 | 4 | 5 | 6, text: "…" } // the text style of its level
{ type: "paragraph", text: "…" } // **bold**, [text](href), "\n" for a line break
{ type: "list", ordered: boolean, items: [[ …blocks ], [ …blocks ]] } // each item is a list of blocks
{ type: "table", rows: [[ { header: true, text: "…" }, … ], …] } // header cells are th

The demo’s service texts start with a level-6 heading and use paragraphs with bold runs (one service adds level-2 and level-3 headings); the posts use level-3 headings (the post page writes the highest one as an h2, its look unchanged: RichText topLevel={2}), paragraphs, bulleted lists and, in three posts, a table; the legal texts use level-2 and level-3 headings, paragraphs and lists. There is no italic. Convert your CMS’s rich text to these blocks in your mapping, bold as **…** and links as text (how). Many rich-text editors have no table by default: check that yours can hold one (or add a table plugin) before you move the posts that carry one, and map it to rows of cells.

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 and the share image) 1920 × 1280 (3 : 2)
A post’s image (the card and the wide cover) 1920 × 1280 (3 : 2)
A dentist’s image 600 × 750
An outcome’s images 600 × 400 each
A review’s photo 160 × 160 (shown round)

A CMS gives full image URLs: the image components (FillImage and SizedImage in src/design-system/components/media/) and the share images take either a /images/<file> path or a URL (isRemote() and imageUrl() in src/design-system/utils/image.ts). Allow the CMS’s image host in astro.config.mjs (image.domains) so Astro resizes its photos too (Images).