Expand description
Link transformation for trailing-slash URL convention.
When markdown files are served with trailing-slash URLs (e.g., docs/guide.md → /docs/guide/),
relative links in the markdown need to be adjusted so they resolve correctly from the browser’s
perspective.
§Problem
A link [other](other.md) in docs/guide.md:
- Filesystem: refers to
docs/other.md(sibling file) - From URL
/docs/guide/: browser resolvesother.mdas/docs/guide/other.md(WRONG) - Correct URL:
/docs/other/
§Solution
Transform relative links by:
- Adding
../prefix for regular markdown files (not index files) - Replacing markdown extensions with trailing slash
- Collapsing index file references to their directory
Structs§
- Link
Transform Config - Configuration for link transformation.
Functions§
- filesystem_
markdown_ page_ probe - Builds the probe used in server and build mode: ask the path resolver — the very code a live HTTP request goes through — whether the URL resolves to a markdown file.
- make_
relative_ url - Convert an absolute URL path to a relative URL from the given depth.
- transform_
link - Transform a relative link URL for the trailing-slash URL convention.
Type Aliases§
- Markdown
Page Probe - Answers “does this absolute, percent-decoded site URL address a markdown page?” for an authored link target that carries no markdown extension.