feat: support rewriting a doc's image source to the current branch #252
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.
Important
This change should have zero impact on the current status of the docs, instead it should make it easier for us to manage images in the future.
From this discussion with Tanner: https://discord.com/channels/719702312431386674/1252133993172697098
Right now, when any of the TanStack projects move to a new major version, we keep all the content of the previous major versions in their own branches. Since we generally have a "main" branch, old branches (v1, v2, ...), and future branches (alpha, beta, ...), this creates a problem when we need to show images in the markdown content in the respective projects.
Currently, when including an image source like
https://github.com/TanStack/router/main/docs/assets/beta.png
it gets rendered from markdown "as-is" regardless of which branch the doc is in. This creates a problem where this image's source would need to remain "as-is" without ANY changes to its name or content till the end of time since it'd have possible effects on the docs for the older branches. Should you decide to make a change to the image source (filename or content) in a documentation markdown file, it'd need massive amounts of coordination since changes would need to be made to all of the previous versions as well.With this change, it'd lock the image source's branch to whatever the current reference branch is provided the source is the same project's repo.
When the project is "router" and the current branch is "alpha", with the image pointing at "main", it'll be rewritten to point at "alpha":
When the project is "router" and the current branch is "alpha", an image from "Table" will be returned as-is.