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

Slugify 生成重复的锚点 #4803

Closed
NeverBehave opened this issue May 18, 2020 · 6 comments
Closed

Slugify 生成重复的锚点 #4803

NeverBehave opened this issue May 18, 2020 · 6 comments
Labels

Comments

@NeverBehave
Copy link
Collaborator

由于 Slugify 生成锚点时仅使用当前标题
在文档中, 部分分类中的二级标题由于类型一致会导致生成相同的锚点

Related:

建议

唯一化锚点, 用remark走一下语法树,slugify单独使用1-2级标题生成

相关项目

https://github.com/remarkjs/remark-slug

@DIYgod DIYgod added the docs label May 18, 2020
@NeverBehave
Copy link
Collaborator Author

https://markdown-it.github.io/
https://github.com/markdown-it/markdown-it/blob/master/docs/architecture.md

markdown-it 并不是生成AST, 这样子的话相关功能实现起来会有点困难

@NeverBehave
Copy link
Collaborator Author

NeverBehave commented May 19, 2020

@DIYgod 研究了一下, 现在有两种解决方案

  1. 在文档.md中添加id

类似lint排版, 直接给需要做层级判断的文档生成对应的id标签, vuepress生成的时候将直接采用指定的id

  1. markdown-it 插件

重新实现一套 https://github.com/valeriangalliat/markdown-it-anchor

目前我手里有一个完成的版本, 但是没有处理用户手动制定的部分, 有点耦合到本项目
写好了, 可以看看效果了

@NeverBehave
Copy link
Collaborator Author

顺便提一下, netlify 生成文档的preview应当保留 (看了一下检查, 似乎是被移除了)
方便检查新pr文档内容的问题和针对docs类修订的审核

@hoilc
Copy link
Contributor

hoilc commented May 19, 2020

试了下,看起来没什么问题,辛苦~

@DIYgod
Copy link
Owner

DIYgod commented May 19, 2020

顺便提一下, netlify 生成文档的preview应当保留 (看了一下检查, 似乎是被移除了)
方便检查新pr文档内容的问题和针对docs类修订的审核

配额不够了,不关要扣 7 刀了

@NeverBehave
Copy link
Collaborator Author

NeverBehave commented May 20, 2020

@DIYgod https://www.netlify.com/legal/open-source-policy/
考虑过这个吗 @DIYgod
给文档页脚加上netlify的标志,配上一个code of conduct应该就能过了
已经是的了噗

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

No branches or pull requests

3 participants