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
12 stars 4 forks source link

add "base" option & fix paths containing spaces #5

Closed 7frank closed 8 months ago

7frank commented 8 months ago
vernak2539 commented 8 months ago

hey @7frank! thanks for the contribution. I've made the latest commit to update a few things. These include:

  1. Changing the location where the URL is decoded (and how - unescape is depcreated, so used decodeURI)
  2. Commented out some code
    • I'll comment on the code with some questions I have!

I've also added a test to understand what this functionality will provide, which we may want to update in the near future

vernak2539 commented 8 months ago

Side note, you can use the astro config like below instead of using a function

import { defineConfig } from "astro/config";
const base="/ai-ui-playground"
export default defineConfig({
  base,
  markdown: {
-    rehypePlugins: [()=>rehypeAstroRelativeMarkdownLinks({base})]
+    rehypePlugins: [[rehypeAstroRelativeMarkdownLinks, {base}]]
  }
// ...
})
vernak2539 commented 8 months ago

Hey @7frank, I'm going to remove the "base" functionality for now in order to get the normalisation of the URL path merged.

I'll come back to this once I have a bit more time to look at the docs and play around with it a bit more! Feel free to open another PR if you'd like. Tracked in https://github.com/vernak2539/astro-rehype-relative-markdown-links/issues/7.

vernak2539 commented 8 months ago

Released in v0.6.1