You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: prepend base path to absolute URLs for subdirectory deployments
Add rehype-base-images plugin for image src attributes and update
rehype-markdown-links to prepend base path to absolute hrefs. Fixes
broken links/images when deploying to GitHub Pages project sites
(e.g., user.github.io/repo/).
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* For absolute paths starting with /docs/, the /docs prefix is stripped
12
12
* since the Astro site serves content from the docs directory as the root.
13
+
* The base path is prepended to absolute paths for subdirectory deployments.
13
14
*
14
15
* Affects relative links (./, ../) and absolute paths (/) - external links are unchanged
15
16
*/
@@ -21,9 +22,15 @@ import { visit } from 'unist-util-visit';
21
22
*
22
23
* The returned transformer walks the HTML tree and rewrites anchor `href` values that are relative paths (./, ../) or absolute paths (/) pointing to `.md` files. It preserves query strings and hash anchors, rewrites `.../index.md` to the directory root path (`.../`), and rewrites other `.md` file paths by removing the `.md` extension and ensuring a trailing slash. External links (http://, https://) and non-.md links are left unchanged.
23
24
*
25
+
* @param {Object} options - Plugin options
26
+
* @param {string} options.base - The base path to prepend to absolute URLs (e.g., '/BMAD-METHOD/')
24
27
* @returns {function} A HAST tree transformer that mutates `a` element `href` properties as described.
0 commit comments