Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSG for Editorial Articles #107

Merged
merged 2 commits into from
Mar 10, 2022
Merged

SSG for Editorial Articles #107

merged 2 commits into from
Mar 10, 2022

Conversation

j0nas
Copy link
Contributor

@j0nas j0nas commented Mar 9, 2022

SSG for Editorial Articles

Intent

A continuation of #105, using the same approach for Editorial Articles on /article/:slug.

Description

Not much is different here from #105. I've added an extra .filter(({ params: { slug } }) => Boolean(slug)); to getStaticPaths because accessing /article/ without a slug is not supposed to be a valid route. Otherwise I've kept the code much the same as for [[...slug]].tsx.

Testing this PR

I've set up a new webhook for testing purposes. It should be configured exactly the same as the webhook for production, except that it points to this branch's Preview Deployment instead.

  1. Open the Realtime Logs for the latest commit of this PR and filter on the api/preview Function
  2. Open the Test article on this branch's Preview Deploy
  3. Make a change in the Test article and publish it
  4. Verify that a request is logged in the Realtime Logs, and that refreshing the Test article renders the change you made

@vercel
Copy link

vercel bot commented Mar 9, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

structured-content-2022-web – ./web

🔍 Inspect: https://vercel.com/sanity-io/structured-content-2022-web/BvQE1hd72AhtuZztvzHrNfXbjp6x
✅ Preview: https://structured-content-2022-web-git-article-ssg.sanity.build

structured-content-2022-studio – ./studio

🔍 Inspect: https://vercel.com/sanity-io/structured-content-2022-studio/9rUN1fZ421huFm4igzxb8PkUWgEZ
✅ Preview: https://structured-content-2022-studio-git-article-ssg.sanity.build

Copy link
Collaborator

@oyvind-stenhaug oyvind-stenhaug left a comment

Choose a reason for hiding this comment

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

Is there an incorrect link in the PR description's "Testing" section? I don't see anything on the "Realtime logs" page.

The page is updated, though, so that part works.

@j0nas
Copy link
Contributor Author

j0nas commented Mar 10, 2022

Is there an incorrect link in the PR description's "Testing" section? I don't see anything on the "Realtime logs" page.

@oyvind-stenhaug What does "not see anything" mean in this case? Are you getting a 404, or are no entries showing?

@oyvind-stenhaug
Copy link
Collaborator

@j0nas Sorry for the ambiguity… It meant no entries showing. It just kept saying "Awaiting new requests…"

I think I figured out the issue. The "Realtime Logs" link points to the URL

https://vercel.com/sanity-io/structured-content-2022-web/BvQE1hd72AhtuZztvzHrNfXbjp6x/functions?name=api%2Fpreview

but when I instead tried

https://vercel.com/sanity-io/structured-content-2022-web/BvQE1hd72AhtuZztvzHrNfXbjp6x/functions

just now, the log entry showed up. api/previewapi/revalidate

@oyvind-stenhaug
Copy link
Collaborator

Will the article route rewrites be handled in a third PR?

@j0nas
Copy link
Contributor Author

j0nas commented Mar 10, 2022

api/previewapi/revalidate

@oyvind-stenhaug 🤦 I fixed the link in the README description now, sorry. Thank you.

Will the article route rewrites be handled in a third PR?

Yeah, if at all. I'm still not sure what the redirects are used for, and I don't actually think they can be added on-the-fly; I'm assuming Next's routing is built on top of Express, which doesn't support updating routes after initialization. So triggering a redeploy via CI is the way to solve that. Not sure whether articles are added so often that this is worth automating. I can ask @kmelve about this on Slack.

@j0nas j0nas merged commit 63a11e8 into main Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants