dumi icon indicating copy to clipboard operation
dumi copied to clipboard

feat: parse the file link to route in markdown

Open ppbl opened this issue 4 years ago • 7 comments

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

  • [x] 新特性提交 / 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

close #238

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

解析 md 文件 link 的时候,通过目标 md 路径提取文件信息,根据 FrontMatter 及项目相关配置生成最终路由,替换链接。

相比之前的一些改动:

现在,只有在项目构建之后有对应路由的情况下,才会对链接进行替换 也就是说,只有 md 文件中引入的路径在 opts.resolve.includes 里面且没有被排除掉,并且目标路径文件存在的情况下。

之前像这样无效的链接, [不在文档路径或文件不存在](../outer.md) , 仅仅删除 .md 后缀没有意义,现在不做处理

📝 更新日志 / Changelog

Language Changelog
🇺🇸 English suport parse the file link to route in markdown
🇨🇳 Chinese 支持解析 markdown 中的文件链接到路由

ppbl avatar Aug 27 '21 08:08 ppbl

😭 Deploy PR Preview failed.

github-actions[bot] avatar Aug 27 '21 08:08 github-actions[bot]

🎊 PR Mobile Preview has been successfully built and deployed to https://dumi-mobile-preview-pr-852.surge.sh

github-actions[bot] avatar Aug 27 '21 08:08 github-actions[bot]

/rebase

PeachScript avatar Aug 30 '21 13:08 PeachScript

Codecov Report

Merging #852 (aca1e44) into master (57d4133) will increase coverage by 0.10%. The diff coverage is 100.00%.

:exclamation: Current head aca1e44 differs from pull request most recent head ab08667. Consider uploading reports for the commit ab08667 to get more accurate results Impacted file tree graph

@@            Coverage Diff             @@
##           master     #852      +/-   ##
==========================================
+ Coverage   94.61%   94.71%   +0.10%     
==========================================
  Files         112      113       +1     
  Lines        2581     2613      +32     
  Branches      826      835       +9     
==========================================
+ Hits         2442     2475      +33     
+ Misses        135      134       -1     
  Partials        4        4              
Impacted Files Coverage Δ
...es/preset-dumi/src/routes/getRouteConfigFromDir.ts 96.87% <100.00%> (+1.87%) :arrow_up:
...s/preset-dumi/src/routes/getRouteConfigFromFile.ts 100.00% <100.00%> (ø)
...ackages/preset-dumi/src/transformer/remark/link.ts 92.85% <100.00%> (+1.55%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 57d4133...ab08667. Read the comment docs.

codecov[bot] avatar Aug 30 '21 13:08 codecov[bot]

突然发现 getRouteConfigFromFile 是否可以和 getRouteConfigFromDir 的 https://github.com/umijs/dumi/blob/master/packages/preset-dumi/src/routes/getRouteConfigFromDir.ts#L103 这部分共用一个逻辑, 多的只是需要单独判断文件路径~

ppbl avatar Aug 30 '21 14:08 ppbl

突然发现 getRouteConfigFromFile 是否可以和 getRouteConfigFromDir 的 https://github.com/umijs/dumi/blob/master/packages/preset-dumi/src/routes/getRouteConfigFromDir.ts#L103 这部分共用一个逻辑, 多的只是需要单独判断文件路径~

可以试试,目前看重复逻辑确实有点多

PeachScript avatar Aug 30 '21 14:08 PeachScript

/rebase

ppbl avatar Aug 30 '21 18:08 ppbl

❤️ 感谢贡献,dumi v1 不再更新,PR 将会关闭;dumi v2 已发布,欢迎继续参与 dumi 的建设,https://d.umijs.org/

PeachScript avatar Jan 28 '23 09:01 PeachScript