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

Does not work with index pages #2

Closed WilfSilver closed 9 months ago

WilfSilver commented 10 months ago

I have just tested this on a basic astro website, and I used the following link:

[some text](./projects/index.md)

I would expect this link to take you to localhost:4321/projects, however instead it takes you to localhost:4321/projects/index

vernak2539 commented 9 months ago

Ahh interesting. Just so I understand correctly, you're wanting to replicate how index.html files work inside of directories?

Do you happen to have a simple repo that reproduces the issue? It would be helpful when I work to try to fix it!

Thanks (Sorry for the late reply!)

WilfSilver commented 9 months ago

Hey, yeah I've just uploaded a repo: https://github.com/WilfSilver/astro-md-links-issue-example, which you should just be able to go:

yarn dev

and then click on the link on the homepage to see the issue.

After setting this up, I've actually noticed 2 issues in this place.

The second issue is not particularly related to this and is more dependent on the template you are using. The template of the project is starlight and so all the documentation files are stored in docs. This means the link on the homepage takes you to /docs/guides/index, instead of the actual address /guides (I feel like the docs can probably just be fixed by a configuration option or something).

However if you do go to /guides/index, it still prints out a 404 page and therefore, it should be expected that the link should go to /guides instead, however I don't know if this is different in other themes...

vernak2539 commented 9 months ago

Thanks for this! I'll hopefully have a look in a couple days and get back to you!

vernak2539 commented 9 months ago

I believe I got it working in https://github.com/vernak2539/astro-rehype-relative-markdown-links/pull/3. This should solve for the index.md files. It also introduces a new config option to designate a custom content path (yet to be documented), which should hopefully fix the second issue you've run into.

I'll likely be able to test it out on the repo provided in a few days, but if you beat me to it, let me know!

vernak2539 commented 9 months ago

This is fixed by #3 and released in ~v0.5.0~ v0.5.1

vernak2539 commented 9 months ago

Thanks for helping and being responsive @WilfSilver