♻️ Make the url a site reads itself as a context api - #1250
Merged
Merged
Conversation
Contributor
|
🚀 Deploy Preview Ready!
|
This branch was successfully deployed
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.
Motivation
The site builds absolute urls in four places — the sitemap, the blog feed,
llms.txt, and every page's canonical link — and each one derived its origin byreaching for the request through
useAbsoluteUrlFactory, a helper parked in thecurrent-request plugin.
That left no seam. What a document advertises was fixed by whatever served it,
and the one url that names production, the canonical link, was a string literal
inside a JSX layout component. A plugin module is middleware; it should not also
be where url logic lives.
Approach
www/context/url.tsis an api built withcreateApi, alongsidefetch,processandlogger:urlApi.aroundcan now rebase either, and becauseurlresolves one path at atime rather than handing back a builder, middleware sees each path and can
rewrite some while leaving others alone.
The call sites that consumed the old builder synchronously move to
all(): thesitemap's entries, the feed's items, and the package list in
llms.txt.plugins/current-request.tsis left holding only its plugin.Tests
This is a pure refactor, so the check is that nothing it produces changed. I
booted the site on this branch and on its base and diffed the documents:
deno fmt,deno lint,deno checkclean; the unit suite passes.Stack
This sits on #1248 and is a prerequisite for #1247, which was carrying it:
Based on
tm/staticalize-baseso the diff shows only its own six files; GitHubretargets it to
v4when #1248 merges.