vernak2539 / astro-rehype-relative-markdown-links

Rehype Plugin for Astro that allows for usage of relative links between markdown files
https://www.npmjs.com/package/astro-rehype-relative-markdown-links
15 stars 4 forks source link

feat: transform any anchor element #35

Open techfg opened 7 months ago

techfg commented 7 months ago

Currently, the plugin only transforms urls on href for anchor elements that are immediate children of the root node in the tree.

It would be possible to transform any url that points to an md/mdxfile regardless of where it "lives" in the tree and/or what type oftag type` it is.

For example, if the markdown contains the following, the transform will not occur:

This is a manual <a href="./my-post.md">My Post</a> anchor element

A couple of ways this could be approached:

  1. Leave currently functionality as-is, only transform on markdown style links (e.g., my link
  2. Expand to include any href on any anchor element within the document
  3. Expand to include any url

Option 2 & 3 could be baked in or exposed via some test option that allows a function to be passed to determine if the url should be transformed or not.

This is definitely a nice to have I think but wanted to log it for future consideration.