Skip to content

♻️ Make the url a site reads itself as a context api - #1250

Merged
taras merged 0 commit into
tm/staticalize-basefrom
tm/url-api
Sep 27, 2026
Merged

taras merged 0 commit into
tm/staticalize-basefrom
tm/url-api

Conversation

@taras

@taras taras commented Sep 27, 2026

Copy link
Copy Markdown
Member

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 by
reaching for the request through useAbsoluteUrlFactory, a helper parked in the
current-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.ts is an api built with createApi, alongside fetch,
process and logger:

export interface UrlApi {
  url(path: string): Operation<string>;
  canonical(options: { base: string }): Operation<string>;
}

export const { url, canonical } = urlApi.operations;

urlApi.around can now rebase either, and because url resolves one path at a
time 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(): the
sitemap's entries, the feed's items, and the package list in llms.txt.
plugins/current-request.ts is 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:

IDENTICAL  llms.txt
IDENTICAL  sitemap.xml
IDENTICAL  canonical link
DIFFERS    blog/feed.xml   <lastBuildDate> only, which is new Date()

deno fmt, deno lint, deno check clean; the unit suite passes.

Stack

This sits on #1248 and is a prerequisite for #1247, which was carrying it:

#1245  tm/agents-contract
#1248  tm/staticalize-base
       tm/url-api            ← this
#1247  tm/markdown-routes

Based on tm/staticalize-base so the diff shows only its own six files; GitHub
retargets it to v4 when #1248 merges.

@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Deploy Preview Ready!

Effection is a structured concurrency and effects framework for JavaScript.
Effection is a structured concurrency and effects framework for JavaScript.

This branch was successfully deployed

1 active deployment
Preview — 1a754b61 Deployed Sep 27, 2026 by taras via deploy-preview #1392
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant