Skip to content

Conversation

@jurgenbelien
Copy link
Contributor

@jurgenbelien jurgenbelien commented Jun 28, 2025

Changes

Head Start would benefit from more dynamic routing where:

  • a single routing pattern could be connected to different DatoCMS models
  • where part of the records for a DatoCMS model are pre-rendered and part are server-rendered.

In the current setup this is difficult to achieve because the @pages/*.astro files handle many concerns:

  • router: match URLs
  • controller: fetch data needed to define static paths, fetch data for template, possibly other logic
  • view: render specific template

This PR introduces a new architecture pattern to allow mixing models and mixing pre-rendered and server-rendered pages by using:

  • src/views/ that are only concerned with fetching record data and rendering a template with it
  • src/pages/ that are only concerned with route matching, fetching collection data to determine paths, defining if a page should be pre-rendered or not.

Associated issue

N/A

How to test

Checklist

  • I have performed a self-review of my own code
  • I have made sure that my PR is easy to review (not too big, includes comments)
  • I have made updated relevant documentation files (in project README, docs/, etc)
  • I have added a decision log entry if the change affects the architecture or changes a significant technology
  • I have notified a reviewer

@jurgenbelien jurgenbelien requested a review from jbmoelker June 28, 2025 09:37
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jun 28, 2025

Deploying head-start with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5543945
Status: ✅  Deploy successful!
Preview URL: https://fb434742.head-start.pages.dev
Branch Preview URL: https://feat-flex-prerender.head-start.pages.dev

View logs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since both catch all routes now just have a single file, we could change this to:

pages/[locale]/
  [...serverPath].astro
  [...staticPath].astro


export const prerender = false;

export async function getStaticPaths() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these actually used in this server-rendered route? Or is this now the catch all route in production?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants