facebook / facebook/docusaurus

Blog - Relative links in blog truncated content (list view) are breaking

Offen
#9,731 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
TypeScript
Sterne
66.2k
Forks
10k
Ø Merge
1 T. 3 Std.
Gemergte PRs (30 T.)
52

Beschreibung

### 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

Links such as `[heading](#headingId)` will work on the actual blog post page

But those links won't work on the list views where the blog is truncated with the `{/* truncate */}` marker.

This is because those relative links are resolved against the current page, and not the blog post permalink.

We should write a Remark plugin that will resolve the blog post links so that we have absolute links in list views, ensuring the links work in both list and detail views.

---

Example in production: https://docusaurus.io/blog/tags/search

![CleanShot 2024-01-11 at 19 43 10](https://github.com/facebook/docusaurus/assets/749374/ef82e80c-73d7-4ea9-a5ae-241ab544349d)

This link doesn't work because the heading is not available on this page.

(I'm going to remove this example so it will not be browsable soon)

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.