Skip to content

🐛 Honor the path component of --base - #16

Merged
taras merged 1 commit into
mainfrom
base-path
Sep 26, 2026
Merged

taras merged 1 commit into
mainfrom
base-path

Conversation

@taras

@taras taras commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Motivation

Closes #12.

A base with a path produced urls without it, so a site published under a subpath could not be staticalized. With --base https://frontside.com/effection, both the rewritten html and the sitemap said https://frontside.com/llms.txt.

This is why the Effection site carries its canonical path separately from --base: it builds to effection.netlify.app but is served at frontside.com/effection, and today those are two places that have to agree about where the site lives.

Approach

rebase(source, base) in the new rebase.ts maps a url on the crawled site onto the base, taking the protocol, host and port as before and prefixing the base's path. A base without a path contributes nothing, so existing behavior is unchanged.

Both rewrite sites now call it. They had the same three lines duplicated — downloader.ts in three places (link[href], [src], [content]) and the sitemap writer in staticalize.ts.

On-disk layout is untouched: output still mirrors the crawled site's paths, and the base path is a fact about the deployment, not the directory.

Verification

Ran the repro from the issue. out/index.html and all three <loc>s now carry /effection:

out/index.html   <link rel="alternate" href="https://frontside.com/effection/llms.txt">
out/sitemap.xml  <loc>https://frontside.com/effection/llms.txt</loc>

Plus a test covering the base path through link[href], [src], [content] and the sitemap. It asserts on the sitemap's raw <loc> text rather than the entry key, so it does not collide with #15.

#17 is stacked on this branch, and folds its text-body substitution into the same rebase.

Rebased onto main now that #15 has merged, so the sitemap writer keeps the url entry key from that PR and
takes its <loc> from rebase. The port: 0 test-server commit came along with #15 and is no longer part of
this branch, which is now a single commit.

@taras
taras added this pull request to stack #18 September 26, 2026 13:06
@taras
taras requested a review from cowboyd September 26, 2026 13:39

@cowboyd cowboyd left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍🏻

Both rewrite sites copied only the origin from the base, so a site
published under a subpath could not be staticalized: `--base
https://frontside.com/effection` produced `https://frontside.com/llms.txt`.

The origin copy is now a `rebase` function that maps a url on the crawled
site onto the base with the base's path as prefix, shared by the html
attribute rewrite and the sitemap writer, which had the same three lines.

Closes #12
@taras
taras merged commit c4e7dea into main Sep 26, 2026
1 check passed
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.

--base ignores its path component

2 participants