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

feat: page-tab default tab supports internationalized interpolation #1860

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Wxh16144
Copy link
Member

@Wxh16144 Wxh16144 commented Aug 26, 2023

🤔 这个变动的性质是?/ What is the nature of this change?

  • 新特性提交 / New feature
  • bug 修复 / Fix bug
  • 样式优化 / Style optimization
  • 代码风格优化 / Code style optimization
  • 性能优化 / Performance optimization
  • 构建优化 / Build optimization
  • 网站、文档、Demo 改进 / Website, documentation, demo improvements
  • 重构代码或样式 / Refactor code or style
  • 测试相关 / Test related
  • 其他 / Other

🔗 相关 Issue / Related Issue

💡 需求背景和解决方案 / Background or solution

需求背景

社区反馈群反馈 tabs 第一个按钮标题无法修改。

image

解决方案

读取当前页面 frontmatter 信息。优先使用 title ,其次使用国际化 title

在默认 tab 保持国际化语言情况下,支持国际化插值来自定义第一个标题。

example:

"content.tabs.default": "Doc",

"content.tabs.default": "Doc-{title}",

proview:

image

📝 更新日志 / Changelog

Language Changelog
🇺🇸 English page-tab default tab prioritizes frontmatter title
🇨🇳 Chinese 页面 tab 默认选项优先采用当前 frontmatter title

@vercel
Copy link

vercel bot commented Aug 26, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dumi ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 27, 2023 5:13am

Copy link
Member

@PeachScript PeachScript left a comment

Choose a reason for hiding this comment

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

这么改可能会有 Breaking Change,页面标题和该页面所属的第一个 Tab 的标题是两个概念,这个方案会使得现有使用约定式 Tab 的项目第一个 Tab 的标题都被默认改变,这其实也会影响全局文档 Tab 的一致性

以及页面级的自定义暂时没想清楚是否要支持,目前个人是倾向于不支持的,以避免影响全局文档 Tab 的一致性;如果讨论下来需要支持的话,应该要新开一个 FrontMatter 配置项来规避 Breaking Change

@Wxh16144 Wxh16144 changed the title feat: page-tab default tab prioritizes frontmatter title feat: page-tab default tab supports internationalized interpolation Aug 27, 2023
@Wxh16144
Copy link
Member Author

更新了一个版本, 默认将读取到的 frontmatter 传递给国际化,开发者可以通过修改国际化文案配合自己约定 frontmatter ,实现自定义。

@PeachScript
Copy link
Member

开发者可以通过修改国际化文案配合自己约定 frontmatter ,实现自定义

什么场景下用户需要把 FrontMatter 的数据作为默认 Tab 标题的一部分 👀

@Wxh16144
Copy link
Member Author

开发者可以通过修改国际化文案配合自己约定 frontmatter ,实现自定义

什么场景下用户需要把 FrontMatter 的数据作为默认 Tab 标题的一部分 👀

哈哈哈, 没有 feature request。

@PeachScript
Copy link
Member

没有实际场景的话建议先不加,一个站点的默认 Tab 的语义理应是全局统一的,框架留出这个口子就很可能引导用户创建出不一致的默认 Tab 标题,这会增加文档访问者的理解成本

@Wxh16144 Wxh16144 closed this Aug 27, 2023
@Wxh16144
Copy link
Member Author

我感觉这个可以 pr 可以重新打开,我还是遇到想改 titile 的场景, 我有liang两个包, 想在 changelog 页面显示他们分别的 changelog, 但是现在 title 还是文档,并且 FM 配置的 title 并没有其他作用

image

image

@Wxh16144 Wxh16144 reopened this Feb 25, 2024
@PeachScript
Copy link
Member

想在 changelog 页面显示他们分别的 changelog

约定式 Tab 的设计场景是有附属给默认文档的 Tab 内容,内容是主次关系,但你提到的场景是分类,内容是并列关系,所以和约定式 Tab 的定位是有区别的

并且 FM 配置的 title 并没有其他作用

侧边栏和搜索会用到


我感觉这个场景用二级导航更合适,因为 /changelog/a + /changelog/b/changelog + /changelog?tab=b 比起来会更加符合直觉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants