generate __data.json files as siblings of .html files#11269
generate __data.json files as siblings of .html files#11269Rich-Harris merged 2 commits intoversion-2from
Conversation
🦋 Changeset detectedLatest commit: cb6d1ca The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Makes sense! Although it opens up an edge case bug where cookies doesn't match when it shouldn't. If I'm reading this right then setting a cookie path to /docs.html then it would match /docs.html but not /docs.html__data.json (but it would've previously matched /docs/__data.json). Now I'm not sure if this is really relevant in practise, but it's worth thinking about.
Btw I'm very glad we have this behind helper functions, makes this change really easy
|
That's true - perhaps the thing to do is duplicate the cookie in the edge case where a) the route ends with |
This is a possible solution to #8676. It's technically breaking insofar as it clobbers any routes that happen to end with
.html__data.json, but given how unlikely that is it's not really breaking.It solves the problem (that you can't prerender both
foo.htmlandfoo.html/__data.json) by making the files siblings — the data is generated asfoo.html__data.jsoninstead. This requires no configuration changes, and very little complexity in terms of implementation — no 'is it prerendered?' or 'what do we do with cookies?' questions, just a simple 'does the route end with.html?' check.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.