Conversation
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
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
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 saidhttps://frontside.com/llms.txt.This is why the Effection site carries its canonical path separately from
--base: it builds toeffection.netlify.appbut is served atfrontside.com/effection, and today those are two places that have to agree about where the site lives.Approach
rebase(source, base)in the newrebase.tsmaps 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.tsin three places (link[href],[src],[content]) and the sitemap writer instaticalize.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.htmland all three<loc>s now carry/effection: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
mainnow that #15 has merged, so the sitemap writer keeps theurlentry key from that PR andtakes its
<loc>fromrebase. Theport: 0test-server commit came along with #15 and is no longer part ofthis branch, which is now a single commit.