Open
Conversation
Deploying head-start with
|
| Latest commit: |
e9f24b0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e2bea9cb.head-start.pages.dev |
| Branch Preview URL: | https://feat-new-preview-links.head-start.pages.dev |
This change contains 2 solutions: - an `/api/reroute/page` endpoint to find and redirect to the correct page url - a check in `pages/[locale]/[...path]/index.astro` that redirects to the canonical url if it doesn't match the current url
…new JSON fields for page models
35ee8a7 to
58f5426
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Associated issue
Part of #10
Closes #233
Description
This PR adds preview links to the DatoCMS sidebar so editors can click a link and immediately see the page they're working on: on localhost, the preview environment, or production. We are installing the Model Deployment Links plugin in DatoCMS which adds preview links to the sidebar. When an editor clicks one, it opens the page on the website.
This is a rebased and updated version of
feat/preview-links, #233 updated with the currentmainbranchFor Home and Not Found pages, the URL is simple and known (
/{locale}/and/{locale}/404). But for regular pages, the CMS only knows the page's slug (e.g.my-page), not the full url path, because pages can be nested (/en/parent/my-page/). To solve this, we added a reroute endpoint that looks up the page by slug and redirects to the correct url.How it works
Changes from the original PR (
feat/preview-links) #233main(content layer, new routing, etc.)/api/reroute/page?locale=en&slug=foo) to path-based (/api/reroute/page/en/foo) — the query param approach had a bug where the DatoCMS plugin didn't URL-encode thelocationparameter, causing the slug to be lostHow to test
Create a new DatoCMS sandbox environment and run migrations (
npm run cms:manage)Start the dev server (
npm run dev)Open the CMS, go to the sandbox environment
Open a Page / Home / Not Found record and check the sidebar preview links:
/{locale}/directly/api/reroute/page/{locale}/{slug}: redirects to the full canonical URL (/en/parent/child/)/{locale}/404Verify that:
Checklist