feat: special purpose pages content collection#294
feat: special purpose pages content collection#294jurgenbelien wants to merge 13 commits intomainfrom
Conversation
| '@typescript-eslint/no-unused-vars': ['error', { | ||
| argsIgnorePattern: '^_', | ||
| destructuredArrayIgnorePattern: '^_', | ||
| ignoreRestSiblings: true, |
There was a problem hiding this comment.
This makes omitting propeties from objects in Typescript a whole lot easier.
| return rest; | ||
| }); | ||
|
|
||
| const content = JSON.stringify(renameKeys({ ...site, app }), null, 2); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
ecf76d7 to
3d538b2
Compare
Deploying head-start with
|
| 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 |
3d538b2 to
8c96afc
Compare
MarleenEliza
left a comment
There was a problem hiding this comment.
Looks good!
But I have some concerns:
- 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.
- 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?
72e8c4c to
7bc4476
Compare
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.
I've added it to |
7bc4476 to
da4842d
Compare
| 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), | ||
| ); | ||
| } |
There was a problem hiding this comment.
this migrates any record that has a reference to the old home page to the new home page
| 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), | ||
| ); | ||
| } |
There was a problem hiding this comment.
same for the not found pages, although the chance of that being necessary is slim
ca92d33 to
9d0ced6
Compare
9d0ced6 to
6e3567c
Compare
6e3567c to
7c65408
Compare
Changes
app) settingssite.jsonpages/[locale][...path]/index.astroAssociated issue
Resolves #291
How to test
Checklist