-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
Remove capture shortcodes & warn on future use. #22175
Remove capture shortcodes & warn on future use. #22175
Conversation
Related to issue #20335 |
Deploy preview for kubernetes-io-master-staging ready! Built with commit 325ba87 https://deploy-preview-22175--kubernetes-io-master-staging.netlify.app |
@sftim, |
/kind cleanup |
@kbhawkey I'm worried about the blast radius of a localization team merging a new PR that breaks the website because a page uses a missing shortcode. This way, the updated page doesn't render correctly but the build remains working. I'd like to get Netlify to simulate a merge and then build a preview, which would detect that issue and block a merge, but making that change happen is not an easy ask. |
We can implement additional checks (eg using GitHub Actions) that create a preview merge and then try to run Hugo. That seems to me like it's duplicating what Netlify already does, but it could be useful. |
Instead, removing the capture shortcode will throw a build error. |
I'm wary of having that error happen after a merge to master - it means prompt feedback but also more of a pain to fix. |
layouts/shortcodes/capture.html
Outdated
{{ warnf "Invalid shortcode in %q" .Page.Path }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sftim, What do you think about adding more information to the warning.
It would be helpful to provide the capture_id in the warning message.
I could see leaving lines 1-6 and adding the capture_id
.
Also, add the prefix to identify with the page path:
{{ $_hugo_config := `{ "version": 1 }`}}
{{- $id := .Get 0 -}}
{{- if not $id -}}
{{- errorf "missing id in capture" -}}
{{- end -}}
{{- $capture_id := printf "capture %s" $id -}}
<!--
{{- .Page.Scratch.Set $capture_id .Inner -}}
-->
{{ warnf "Invalid shortcode: in %s, %q" $capture_id (relLangURL .Page.Path) }}
957b2f1
to
c380d08
Compare
Seems fine to me, probably need some other tech lead to approve whilst I get back up to speed. |
layouts/shortcodes/capture.html
Outdated
{{- $capture_id := printf "capture %s" $id -}} | ||
<!-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sftim, Things look good. Would you remove the comment? I'd like to see a clean build/deploy preview
before merging. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed!
Similar to PR #22321 |
If anyone uses the capture shortcode, emit a warning. The website no longer uses capture shortcodes.
c380d08
to
325ba87
Compare
/lgtm |
{{- $capture_id := printf "capture %s" $id -}} | ||
{{- .Page.Scratch.Set $capture_id .Inner -}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: The Scratch set could be removed?
Let's move this forward. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kbhawkey The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
“We got one”. This warning helped me find an issue and submit PR #22397. |
Yes, I saw it in testing this PR. |
After PR #21359 merged, some more capture shortcodes have crept in.
This PR
I chose a warning rather than error to reduce the risk of a misguided merge breaking the site. There's no lint about broken shortcodes, and the CI tests the code from the fork, rather than testing the result of a simulated merge into master.