facebook / facebook/docusaurus

Relative markdown links between blog and docs does not work

Đang mở
#9,117 8 bình luận 1 reaction 0 người được giao Xem trên GitHub
bug difficulty: advanced domain: markdown
Ngôn ngữ chính
TypeScript
Star
66.2k
Fork
10k
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
52

Mô tả

### Have you read the Contributing Guidelines on issues?

- [X] I have read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#issues).

### Prerequisites

- [X] I'm using the latest version of Docusaurus.
- [X] I have tried the `npm run clear` or `yarn clear` command.
- [X] I have tried `rm -rf node_modules yarn.lock package-lock.json` and re-installing packages.
- [X] I have tried creating a repro with https://new.docusaurus.io.
- [X] I have read the console error message carefully (if applicable).

### Description

Hi Docusaurus team,

Love this library - thank you for your awesome work!

I'm looking to link a blog post to a docs page using a relative markdown link, but I receive the following error when I specify `[link to doc](../../docs/doc-page.md)` in the blog post:

`[WARNING] Blog markdown link couldn't be resolved: (../../docs/doc-page.md) in "/home/projects/github-dc5ygn/blog/blog-post.md`

On the other hand, using link without the `.md` (`[link to doc](../../docs/doc-page)`) extension works fine.

Is there a way I can prevent the broken link while preserving the `.md` extension? I'm using an Obsidian plugin to convert wikilinks to internal links and need to keep the `.md` extension for it to work properly.

### Reproducible demo

https://stackblitz.com/edit/facebook-docusaurus-mx3fkh?file=blog%2Fblog-post.md

### Steps to reproduce

1. Go to demo linked above.
2. Wait for the site to compile. You should see a warning: `[WARNING] Docs markdown link couldn't be resolved: (../../docs/doc-page.md) in "/home/projects/facebook-docusaurus-mx3fkh/docs/doc-page.md" for version current`
3. In the website preview on the right, click the menu button (three bars).
4. Click **Blog**.
5. Under the "blog-post" title click **"link to doc"**.
6. You should see a "Page Not Found" error.
7. Edit "blog-post.md" to exclude ".md" from the link: `[link to doc](../../docs/doc-page)`
8. Complete steps 2-5. Link should now work correctly.

### Expected behavior

The link `[link to doc](../../docs/doc-page)` should work regardless of whether or not `.md` is specified.

### Actual behavior

The link `[link to doc](../../docs/doc-page)` only works when `.md` is omitted.

### Your environment

- Public source code: See demo link above
- Public site URL: See demo link above
- Docusaurus version used: 2.4.1
- Environment name and version (e.g. Chrome 89, Node.js 16.4): Node.js 16.20.0
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): N/A

### Self-service

- [ ] I'd be willing to fix this bug myself.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.