Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: Repeat generation and hump naming
  • Loading branch information
sy-records committed Jan 30, 2022
commit e3fe66abb7642c5d8d8ea618add9899848af7946
14 changes: 12 additions & 2 deletions lib/commands/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@ function genSidebar(cwdPath, sidebarPath) {
let filename = path.basename(pathname, '.md')
let splitPath = pathname.split(path.sep)

if (ignoreFiles.indexOf(filename) !== -1) {
return true
}

if (ignoreFiles.indexOf(filename) === -1) {
nodeName = '- [' + filename + '](' + pathname + ')' + os.EOL
nodeName = '- [' + toCamelCase(filename) + '](' + pathname + ')' + os.EOL
}

if (splitPath.length > 1) {
if (splitPath[0] !== lastPath) {
lastPath = splitPath[0]
tree += os.EOL + '- ' + splitPath[0] + os.EOL
tree += os.EOL + '- ' + toCamelCase(splitPath[0]) + os.EOL
}

tree += ' ' + nodeName
Expand Down Expand Up @@ -78,3 +82,9 @@ function getDirFiles(dir, callback) {
}
})
}

function toCamelCase(str) {
return str.replace(/\b(\w)/g, function (match, capture) {
return capture.toUpperCase()
}).replace(/-|_/g, ' ')
}