Conversation
… item type IDs and generate model API keys
…ality. Updated documentation
…o go to, no fallback. Update docs
Deploying head-start with
|
| Latest commit: |
3f958a8
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3685c179.head-start.pages.dev |
| Branch Preview URL: | https://feat-edit-page.head-start.pages.dev |
jurgenbelien
left a comment
There was a problem hiding this comment.
If it weren't for how the PreviewMode works now I think this is a great way to do it. However, since there is already a lot of plumbing in the PreviewMode I'd rather leverage that, meaning showing links to records that are being watched
src/components/PreviewMode/features/EditInDatoCms/EditInDatoCms.astro
Outdated
Show resolved
Hide resolved
src/lib/content/index.ts
Outdated
| } | ||
| } else { | ||
| entry = await getAstroCollectionEntry(collection, combine({ id, locale })); | ||
| entry = await getAstroCollectionEntry(collection, combine({ id, locale })) as BareCollectionEntry<K> | undefined; |
There was a problem hiding this comment.
Why is this necessary? I'm a bit worried about the type assignment
jurgenbelien
left a comment
There was a problem hiding this comment.
Looks good but the type reassignments could hint at an underlying issue. Could you explain why this is necessary? I'd rather have no type reassignments at all honestly.
docs/preview-mode.md
Outdated
|
|
||
| To enable preview mode for a git branch, you must add it to [`config/preview.ts`](../config/preview.ts). Preview branches will deploy as `output: 'server'` rather than `output: 'hybrid'`, ignoring all `getStaticPaths()` and always rendering the page during run-time. The `preview` branch is configured as one of the preview branches and is automatically kept in sync with the `main` branch, so it can be used as preview equivalent, for example from the CMS. | ||
|
|
||
| ### Local development |
There was a problem hiding this comment.
Good suggestion. I would format this as a tip to make it clear. And also because otherwise it cuts the current text section on enabling preview mode in two:
> [!TIP]
> To enable preview mode during local development:
> - Make sure your current git branch is included in [`config/preview.ts`](../config/preview.ts).
> - Set `HEAD_START_PREVIEW_SECRET` and `DATOCMS_READONLY_API_TOKEN` in your local `.env`.
> - Enter preview mode via `/api/preview/enter/?secret=...` (or the preview login form).| <a href={ `/api/preview/exit/?location=${Astro.url}` }>exit preview</a> | ||
| <div class="preview-mode-actions"> | ||
| {/* eslint-disable-next-line astro/jsx-a11y/anchor-is-valid */} | ||
| <a data-edit-record target="_blank">edit page</a> |
There was a problem hiding this comment.
We don't know what type of record this will link to. Could be an event or a person or ... . So I would change the text to "edit in CMS".
There was a problem hiding this comment.
And since it's a [target="_blank"] I would always add rel="noreferrer noopener".
| } | ||
|
|
||
| connectedCallback() { | ||
| if (!this.editableRecord?.id || !this.editableRecord?.type || !this.#datocmsProject) { |
There was a problem hiding this comment.
maybe add a const isLinkableRecord = !this.editableRecord?.id || !this.editableRecord?.type || !this.#datocmsProject to make it easier to read?
Changes
Adds an “edit page” link to the preview bar that links to the current page record editor (when we have id + __typename), so editors can jump from a preview page straight into the CMS record.
Documentation link
See: https://github.com/voorhoede/head-start/blob/feat/edit-page/docs/preview-mode.md#edit-in-datocms-link
How to test
Checklist