Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blog anchor links in paginated lists should be resolved against blog post url, not current url #10287

Open
6 of 7 tasks
afunk-anduril opened this issue Jul 9, 2024 · 5 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@afunk-anduril
Copy link

Have you read the Contributing Guidelines on issues?

Prerequisites

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

Description

Anchor tags shown on an entry of https://docusaurus.io/blog, doesn't go to the entry page's anchor tag. It goes to the https://docusaurus.io/blog#ANCHOR-TAG.

Reproducible demo

No response

Steps to reproduce

  1. go to https://docusaurus.io/blog with a description that links to an anchor tag on the entry's page
  2. Click on anchor tag in the entry page's one-liner description above the truncate line.
  3. Goes to broken link.

Expected behavior

Expect to go to the entry page's anchor, not to stay on the blog's home page.

Actual behavior

Stays on blog's home page.

Your environment

  • Public source code:
  • Public site URL:
  • Docusaurus version used:
  • Environment name and version (e.g. Chrome 89, Node.js 16.4):
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS):

Self-service

  • I'd be willing to fix this bug myself.
@afunk-anduril afunk-anduril added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jul 9, 2024
@OzakIOne
Copy link
Contributor

I'm not sure that I understood, you expect https://docusaurus.io/blog#Docusaurus-3.1 to scroll to Docusaurus 3.1 title ?

@slorber
Copy link
Collaborator

slorber commented Jul 10, 2024

It's hard to understand what it's about indeed, can you please provide a concrete runnable example and screenshots?

What I think I understand is that you have anchor tag links [xyz](#xyz) appearing above the blog <!-- truncate --> marker (if any), so they get rendered in the blog paginated views. And you expect clicking those anchors to lead to https://docusaurus.io/blog/post#xyz instead of https://docusaurus.io/blog/#xyz, is that correct?

@slorber slorber removed the status: needs triage This issue has not been triaged by maintainers label Jul 10, 2024
@Josh-Cena
Copy link
Collaborator

@slorber Yes, I believe what you said is the expected behavior.

I could see a reason for wanting this, and I don't think it's impossible to build—we just need to resolve anchor links to absolute URLs. I'm actually surprised if we are not doing that atm.

@slorber
Copy link
Collaborator

slorber commented Jul 11, 2024

I'm actually surprised if we are not doing that atm.

Afaik no we are not doing that atm.

It's not just anchor links, but all relative links in general (which we advise to not use, but still an edge case to solve)

@Josh-Cena
Copy link
Collaborator

Josh-Cena commented Jul 11, 2024

It occurs to me as safe to normalize them, since each page can only map to one slug. But I'm not sure if the Markdown loader can be aware of the current page's mapped URL, or how we should take care of imported Markdown, etc.

Maybe we can at least do this in the blog plugin that processes the truncated query? Not sure.

@slorber slorber changed the title Blog description links broken Blog anchor links above truncate markers should be resolved against blog post url instead of current url Aug 9, 2024
@slorber slorber changed the title Blog anchor links above truncate markers should be resolved against blog post url instead of current url Blog anchor links in paginated lists should be resolved against blog post url, not current url Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

No branches or pull requests

4 participants