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

enhance(macros/PreviousMenuNext): use the actual title of the document by default #10812

Merged
merged 4 commits into from
Apr 18, 2024

Conversation

yin1999
Copy link
Member

@yin1999 yin1999 commented Mar 29, 2024

Summary

Fixes: #10274

Problem

We used to use localized slugs, so we could generate localized titles through the slugs. But now we have used unified slugs across locales, which causes the {{PreviousMenuNext}} macro to be unable to display localized titles for the menu link.

Solution

Solve this problem by retrieving the title of the page, if the page is not found:

  • for translated documents: try to retrive the title from the default locale (en-US), if still not existed, fallback to generate it from the given slug.
  • for en-US: fallback to generate it from the given slug.

Screenshots

path Before After
/zh-CN/docs/Learn/Accessibility/CSS_and_JavaScript image image
/zh-CN/docs/Learn/Accessibility/HTML image image
/fr/docs/Learn/Accessibility/HTML image image

PreviousMenu macro

{{PreviousMenu}} macro reuses the {{PreviousMenuNext}} macro.

path Before After
/fr/docs/Learn/Accessibility/Accessibility_troubleshooting image image
/ja/docs/Learn/Accessibility/Accessibility_troubleshooting image image

How did you test this change?

Run yarn dev and check the above pages.

@github-actions github-actions bot added the macros tracking issues related to kumascript macros label Mar 29, 2024
@yin1999
Copy link
Member Author

yin1999 commented Mar 29, 2024

/cc @awxiaoxian2020 You may be interested in this :)

@yin1999 yin1999 force-pushed the localize-previousMenuNext branch from 95618e1 to d24c2ff Compare March 29, 2024 02:27
@yin1999 yin1999 marked this pull request as ready for review April 1, 2024 05:38
@yin1999 yin1999 requested a review from a team as a code owner April 1, 2024 05:38
@LeoMcA LeoMcA self-assigned this Apr 17, 2024
Copy link
Member

@LeoMcA LeoMcA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, adds functionality and cleans up some code, a few small queries:

kumascript/macros/PreviousMenuNext.ejs Show resolved Hide resolved
kumascript/macros/PreviousMenuNext.ejs Show resolved Hide resolved
kumascript/macros/PreviousMenuNext.ejs Show resolved Hide resolved
kumascript/macros/PreviousMenuNext.ejs Show resolved Hide resolved
Copy link
Member

@LeoMcA LeoMcA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for those answers, looks good with no changes!

@LeoMcA LeoMcA merged commit 10da897 into mdn:main Apr 18, 2024
10 checks passed
@yin1999 yin1999 deleted the localize-previousMenuNext branch April 18, 2024 11:27
mostafaroshdy1 pushed a commit to mostafaroshdy1/yari that referenced this pull request Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
macros tracking issues related to kumascript macros
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is it possible to show locale title instead of the last path string in main menu of module for macros?
3 participants