Skip to content

feat: special purpose pages content collection#294

Open
jurgenbelien wants to merge 13 commits intomainfrom
feat/special-pages
Open

feat: special purpose pages content collection#294
jurgenbelien wants to merge 13 commits intomainfrom
feat/special-pages

Conversation

@jurgenbelien
Copy link
Copy Markdown
Contributor

@jurgenbelien jurgenbelien commented Jul 20, 2025

Changes

  • Lets ESLint allow rest operator for removing properties from objects.
  • Another update to error reporting
  • Pass noIndex to Pages Content Collection entries
  • Add purpose field to Pages Content Collection entries
  • Migrates HomePage and NotFoundPage singletons to regular Pages
    • These pages are set in Website (app) settings
    • Two separate migrations, one for schema, one for content make this easier
  • Download said settings to site.json
  • Creates a SpecialPages Contentent Collection for 404, home, and others pages to come
  • Drops the Home route, now handled by pages/[locale][...path]/index.astro

Associated issue

Resolves #291

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

Comment thread eslint.config.mjs
'@typescript-eslint/no-unused-vars': ['error', {
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
ignoreRestSiblings: true,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This makes omitting propeties from objects in Typescript a whole lot easier.

return rest;
});

const content = JSON.stringify(renameKeys({ ...site, app }), null, 2);
Copy link
Copy Markdown
Contributor Author

@jurgenbelien jurgenbelien Jul 20, 2025

Choose a reason for hiding this comment

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

I'm not completely sure about this, but I felt I needed it to make sure that the getHref function still works for the homepage.

Another option would be a content collection that would map record Ids to their respective paths, but that would turn the getHref function asynchronous.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I actually think it's nice to have some way to statically determine what the special purpose pages are.
I think this is the most efficient way to select it from a collection, to have the IDs known beforehand and eventually select from a collection based on the ID.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Jul 20, 2025

Deploying head-start with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7c65408
Status: ✅  Deploy successful!
Preview URL: https://30989126.head-start.pages.dev
Branch Preview URL: https://feat-special-pages.head-start.pages.dev

View logs

@jurgenbelien jurgenbelien marked this pull request as ready for review July 20, 2025 20:47
@jurgenbelien jurgenbelien requested a review from jbmoelker July 20, 2025 20:47
Copy link
Copy Markdown
Member

@MarleenEliza MarleenEliza left a comment

Choose a reason for hiding this comment

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

Looks good!

But I have some concerns:

  1. The slug of a page cannot be left empty. Isn't this desirable for the Home Page though? The language buttons in the top right corner still reflect the link with the set slug.
Screenshot 2025-07-21 at 11 28 58 Screenshot 2025-07-21 at 13 21 01
  1. If the specialized pages are unset, the website cannot be built. I know this is by design, but this might be worth mentioning in the docs?

@jurgenbelien jurgenbelien force-pushed the feat/special-pages branch 5 times, most recently from 72e8c4c to 7bc4476 Compare July 22, 2025 11:41
@jurgenbelien
Copy link
Copy Markdown
Contributor Author

jurgenbelien commented Jul 22, 2025

Looks good!

But I have some concerns:

  1. The slug of a page cannot be left empty. Isn't this desirable for the Home Page though? The language buttons in the top right corner still reflect the link with the set slug.

I resolved the issue with the language toggle, and added a test scenario for it. The slug field now has an help text explaining that for home it is ignored.

  1. If the specialized pages are unset, the website cannot be built. I know this is by design, but this might be worth mentioning in the docs?

I've added it to getting-started.md

Comment on lines +159 to +169
for (const record of recordsReferencingHomePage) {
const { id, type, item_type, meta, creator, ...content } = record;
const title = isLocalizedField(content.title)
? content.title[locales[0]]
: content.title;
console.log(`Updating record "${title || id}"`);
await client.items.update(
record.id,
replaceReferences(content, homePageModel.singleton_item.id, home_page),
);
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this migrates any record that has a reference to the old home page to the new home page

Comment on lines +179 to +189
for (const record of recordsReferencingNotFoundPage) {
const { id, type, item_type, meta, creator, ...content } = record;
const title = isLocalizedField(content.title)
? content.title[locales[0]]
: content.title;
console.log(`Updating record "${title || id}"`);
await client.items.update(
record.id,
replaceReferences(content, notFoundPageModel.singleton_item.id, not_found_page),
);
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

same for the not found pages, although the chance of that being necessary is slim

@jurgenbelien jurgenbelien marked this pull request as draft September 8, 2025 06:27
@jurgenbelien jurgenbelien force-pushed the feat/special-pages branch 2 times, most recently from ca92d33 to 9d0ced6 Compare September 9, 2025 12:18
Comment thread config/datocms/migrations/1752588127_featSpecialPages.ts Outdated
@jurgenbelien jurgenbelien marked this pull request as ready for review September 16, 2025 13:46
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.

Special purpose pages

4 participants