Fix pretty slug pages rendering root content (#90)#93
Merged
Conversation
The getPublicPageData handler was force-injecting the root page's blockId whenever the client omitted it. The client omits blockId for every URL without a 32-hex page ID, including pretty slug URLs like /about, so all slug pages rendered the root page. Resolve the current page from the Referer header: map the referring path to a slug in SLUG_TO_PAGE, fall back to a 32-hex match, and only use the root page when nothing else matches.
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.
Summary
/about,/journal) rendered the root page's content instead of their own page./api/v3/getPublicPageDatahandler (added in a759056) force-injected the root page'sblockIdwhenever the client omitted it. The client omitsblockIdfor any URL without a 32-hex page ID — root/and every pretty slug — so all slug pages resolved to the root page.Refererheader: look upSLUG_TO_PAGE[slug], fall back to a 32-hex match in the path, and only use the root page when nothing else matches.Test plan
npm run buildsucceeds/about) mapped to a non-root Notion page and verify:/aboutrenders the/aboutpage content (not root)/still renders the root page/<32-hex-pageId>still resolves correctlywoven.press/aboutandwoven.press/journalwork