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

fix: cannot search for 1-level heading content #1828

Merged
merged 3 commits into from
Aug 13, 2023

Conversation

Zhou-Bill
Copy link
Contributor

🤔 这个变动的性质是?/ 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

#1811

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

  • 一级内容搜索失效
  • 原因是searchWorker.ts 格式化搜索内容 层级少了一层

1
2
3

📝 更新日志 / Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese 修复一级内容搜索失效缺陷

@vercel
Copy link

vercel bot commented Aug 9, 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 12, 2023 4:00pm

compiled/@umijs/plugins/package.json Outdated Show resolved Hide resolved
@@ -119,7 +119,7 @@ function generateSearchMetadata(
const tocSections = routeMeta.toc.reduce<ISearchMetadata[0]['sections']>(
(acc, toc, i) => {
// exclude demo id, to avoid duplicate
if (!demoIds.includes(toc.id) && toc.depth > 1) {
if (!demoIds.includes(toc.id) && toc.depth >= 1) {
Copy link
Member

Choose a reason for hiding this comment

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

感谢贡献,回想了一下当时的考虑,过滤掉 1 级是为了避免页面搜索和一级标题搜索冗余,因为 dumi 会把页面的一级标题作为页面标题,比如搜索『初始化』可以看到冗余的结果

单就这个问题而言,期望结果是:

  1. 输入 1 级标题下的文本,能展示结果,且结果的标题只展示页面标题(什么是 dumi - 什么是 dumi 简化成 什么是 dumi
  2. 输入 1 级标题本身,只展示页面结果不展示标题结果

大致效果:

有空的话看看是否容易调整?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

嗯,这里已调整,就是在匹配toctitle 的时候,看下是否能匹配页面title, 如果是的话就跳过。就等于过滤掉toc 的搜索结果

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.

+1

@PeachScript PeachScript merged commit d114525 into umijs:master Aug 13, 2023
8 checks passed
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.

2 participants