Skip to content

Commit

Permalink
feat: 调整 _getChaptersWithCode() 方法,优化算法
Browse files Browse the repository at this point in the history
  • Loading branch information
yaohaixiao committed Aug 10, 2023
1 parent 3848ee7 commit 7c3fbd1
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion anchors.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion anchors.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/js/outline.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/js/outline.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion outline.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion outline.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yaohaixiao/outline.js",
"version": "3.11.0",
"version": "3.12.0",
"description": "outline.js - 自动生成文章导读(Table of Contents)导航的 JavaScript 工具。",
"main": "outline.min.js",
"scripts": {
Expand Down
7 changes: 3 additions & 4 deletions src/_getChaptersWithCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ const _getChaptersWithCode = (chapters) => {

Object.keys(groups).forEach((group) => {
groups[group].forEach((c) => {
chapters.forEach((o) => {
if (o.pid === c.id) {
o.code = c.code + '.' + o.index
}
const subjects = chapters.filter((b) => b.pid === c.id)
subjects.forEach((o) => {
o.code = c.code + '.' + o.index
})
})
})
Expand Down

0 comments on commit 7c3fbd1

Please sign in to comment.