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

Generated Sidebar Pagination will not use doc Label but the File Name #9781

Closed
3 of 7 tasks
LeonnardoVerol opened this issue Jan 23, 2024 · 6 comments · Fixed by #10025
Closed
3 of 7 tasks

Generated Sidebar Pagination will not use doc Label but the File Name #9781

LeonnardoVerol opened this issue Jan 23, 2024 · 6 comments · Fixed by #10025
Labels
bug An error in the Docusaurus core causing instability or issues with its execution difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. domain: content plugin Related to content plugin emitting metadata for theme consumption

Comments

@LeonnardoVerol
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

When generating pagination from the sidebar, the "Next" and "Previous" Cards will ignore the doc label and default to the file name. (when the doc has no H1 or Title property)

{
	type: 'doc',
	label: 'Quick Start',
	id: 'some_example_doc',
}

Reproducible demo

No response

Steps to reproduce

  1. Create a doc without H1 or Title
  2. Set the sidebar manually with the label property

Expected behavior

The generated Pagination would use the label property from the sidebar and not the file name

Actual behavior

The generated Pagination ignores the label property from the sidebar and uses the file name

Your environment

  • Docusaurus version used: 3.1.0
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): Chrome 120
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): Windows 11 Pro (Version 10.0.22631 Build 22631 )

Self-service

  • I'd be willing to fix this bug myself.
@LeonnardoVerol LeonnardoVerol 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 Jan 23, 2024
@Josh-Cena
Copy link
Collaborator

Yes, something is wrong here.

export function toDocNavigationLink(doc: DocMetadataBase): PropNavigationLink {
const {
title,
permalink,
frontMatter: {
pagination_label: paginationLabel,
sidebar_label: sidebarLabel,
},
} = doc;
return {title: paginationLabel ?? sidebarLabel ?? title, permalink};
}

Our doc navlink transform logic only takes into account the explicit sidebar_label front matter, but not the sidebar label acquired from the explicit sidebar label config. We need to fetch it from the SidebarNavigationItem we already calculated beforehand.

@Josh-Cena Josh-Cena added difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. domain: content plugin Related to content plugin emitting metadata for theme consumption and removed status: needs triage This issue has not been triaged by maintainers labels Mar 3, 2024
@ShubhamPatilsd

This comment was marked as off-topic.

@slorber

This comment was marked as off-topic.

@tylermenezes

This comment was marked as off-topic.

@Abdullah-03
Copy link
Contributor

This should be the order of precedence, correct? Explicitly declared label should have higher priority over front matter.

title: paginationLabel ?? sidebarConfigLabel ?? sidebarLabel ?? title

@Abdullah-03
Copy link
Contributor

side bar label in front matter takes precedence.

Abdullah-03 added a commit to Abdullah-03/docusaurus that referenced this issue Apr 5, 2024
…file name as pagination label rather than the sidebar 'label' defined through item definition

Fixes facebook#9781
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 difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. domain: content plugin Related to content plugin emitting metadata for theme consumption
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants
@tylermenezes @slorber @LeonnardoVerol @Abdullah-03 @ShubhamPatilsd @Josh-Cena and others