Repository navigation
Resolve content links from their source file after rendering. - #7
Merged
Merged
Conversation
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
Relative links in content now resolve from the file that wrote them, and the build fails when one points to a page that doesn't exist.
Previously only links ending in
.md,.mdxor.rmdxwere rewritten. Anything else, like[themes](./themes), was left for the browser to resolve against the page URL. Page URLs end in a slash, so on a page likeguides/semantic-tones.mdx(/guides/semantic-tones/) that link went to/guides/semantic-tones/themes. It only worked by coincidence on folderindexpages.The rule
./themes,../,./components/buttons) resolve from the source file, with or without an extension. They must match a page, or the build fails with the file and the link in the message./blog/) are left as written and aren't checked, so they can point to pages built separately.An extensionless path finds the file first (
a/c.mdx), then the folder page (a/c/index.mdxora/c/c.mdx). A trailing slash checks the folder first. A translated page that links to an untranslated one gets the default-locale page.How it works
renderAppgains anonRendered(document)hook. A single pass (build/page-urls.ts) resolves everyhrefafter Regor renders. That covers Markdown links, raw HTML, Regor components and bound values like:href="nextPage". Code samples, comments and script text are never touched, because they aren't elements.public-hrefs.ts;mdx/linkRewrite.tsis removed as well.ContentRouteIndex) checks links against discovered pages in memory, without touching the disk.Behavior changes
build. Inserve, it shows on that page's error page.BtnLinkandFormAssistLinkno longer turn./xinto/x; relative values are kept and resolved by the page pass.teleport="head") resolves from the page's file.Docs
New Links guide in
guides/, added to the nav and the guides index. The semantic tones guide now uses./themes.Testing
BtnLink, header links, and broken links.