Add rough custom 404 page in astro with quick search#1257
Add rough custom 404 page in astro with quick search#1257ksen0 merged 10 commits intoprocessing:2.0from
Conversation
|
@nbogie for the config, I think that goes in here? If I understand correctly, can be addable to this PR. https://github.com/processing/p5.js-website/blob/2.0/wrangler.jsonc |
|
Do you have any ideas on how to get the user's browser from insisting on lowercase? That seems like a pretty big problem even with 404 implemented |
I'm hopeful that it seems this correction only happens when the user tries hand-correcting the capitalisation of an all-lower-case url in the url bar, and then presses enter, when their browser "knows better" (or can't differentiate wrt to cache lookup). It doesn't seem to happen if the user clicks a link with a corrected capitalisation - this seems to bypass any browser correction, if indeed that's what's happening in the former case. Steps to repeat: (on chrome)
As for preventing this relatively minor correcting, in chrome it looks like it is only possible with "clear browsing history". https://stackoverflow.com/questions/50298340/chrome-changes-url-case |
Testing:
Update: now using wrangler action on github actions, not wrangler manually from cli |
|
Good to go, i think! |
|
Thanks so much for your work on this ! It did look reasonable and I did deploy, however the routes are doing a different thing than expected. Here is me clicking on "curveDetail"* and getting into weird 404: 404.movReproduced with both /curveVertex/ and /curveVertex in path. But feels like surely it's related to trailing slash handling in dev vs prod I have now redeployed from *"It doesn't seem to happen if the user clicks a link with a corrected capitalization - this seems to bypass any browser correction, if indeed that's what's happening in the former case." Alas, not so in general. In Chrome I consistently get the browser talking to itself loop if I click on something I've clicked on before / which is cached. |
|
That looks like clicking on a search result was taking you to the 404 page? And (perhaps) the 404 page wasn't presenting any part of your original link in the search link? (Or perhaps when you get taken to 404 it is snapping to a certain url). |
|
So, the JS in the 404 astro page was getting statically compiled and the values locked in from the first render during build. My bad for not test-deploying the full 404 in my toy astro site. I have successfully recreated the problem now with a cloudflare deploy of the the website repo and will change it to use JS that definitely runs client-side instead! |
|
Fixed! You can test it out here: https://p5-js-website-beta.neillzero.workers.dev/reference/p5/basestrokeshader/ (The above is a deploy of a branch that's very slightly different from this PR branch, with (only) some necessary removals of custom p5.js domains from the wrangler config) |
|
In my tests I can't recreate the (possible routing) issue shown in Kit's video where the user clicks a search result and it goes to the 404 page. I wonder if that's not actually a routing issue, but this other issue of the browser "correcting" the "wrong" capitalisation of a URL it's been to before. One easy way to tell is to use a browser that's not been to those URLs before. |
Yes I believe that must be it! Was fine in incognito. |
Something weird with style (actually also on https://p5-js-website-beta.neillzero.workers.dev/reference/p5/buildfiltershader/):
|
|
I fixed the social arrows by using a Head + BaseLayout , bringing it into line with most of the pages on the site. But I wasn't able to reproduce the "footer unmoored" issue. (The Head component sets encoding - that was likely the social arrows issue.) deployed here: https://p5-js-website-beta.neillzero.workers.dev/reference/p5/buildstrokeshader/ |


Addresses #1256
changes
1. custom 404 page with populated search link
Adds a rough custom 404 page in astro (
/src/pages/404.astro) which presents user with a quick search option to search the website (using the website) for pages matching the last part of their path.Example:
When the user visits the broken URL: https://beta.p5js.org/reference/p5.font/texttocontours/
the custom 404 page includes a search link to: https://beta.p5js.org/search/?term=texttocontours
2. Cloudflare config
per the astro docs for cloudflare deployment
https://docs.astro.build/en/guides/deploy/cloudflare/#404-behavior
this PR changes
wrangler.jsoncto setnot_found_handlingas follows:This will cause it to look for a 404 page in
.dist/404.html. I have confirmed locally astro build is putting our custom 404 page at that file path.(Note to anyone testing with other their own astro stuff: the popular "starlight" theme will overwrite this page by default with its own 404 page. (this can be disabled.))