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

bug: Transformed url does not respect custom slug #14

Closed techfg closed 7 months ago

techfg commented 7 months ago

When a page contains a custom slug, the transformed url is not respecting it and instead, generating the astro default slug via githug-slugger.

For example, in a file /posts/post-3.md:

---
title: Post 3
slug: post.3
---

[Post 3](./post-3.md)

Should result in /posts/post.3 but instead results in /posts/post3.

It appears in #9 logic was added to handle special characters, etc. which makes sense and was needed. However, if a custom slug exists, it should use it.

Astro appears to handle this by generating the default slug but then checking for a custom slug and if exists, using it, else falling back on default.

Repro:

With Proposed Fixes from PR #21:

Steps to repro:

  1. Open repro
  2. Click on Post 1 link
  3. Click on either link under Repro for Issue #14

Expected Result: Link should navigate to /posts/post.3 or /posts/archive.md/archive-1 (depending on link chosen)

Actual Result: The . is stripped and results in 404

Additional Info: You can see all links that Astro generates on home page under Issue #14 heading

techfg commented 7 months ago

FYI - Edited OP to a Stackblitz to the repro that contains the proposed fixes from #21.

vernak2539 commented 7 months ago

Released in v0.9.0! Thanks!