Skip to content

 This project is dedicated to collecting high-quality macOS software and organizing them systematically by different categories for easy search and use.

chore: Refactor getHeadingText to remove title parameter (#1707)

Vignesh Skanda24a3bcecedd6
diff --git a/build/ast.mjs b/build/ast.mjs
index 5167a21d..d171d017 100644
--- a/build/ast.mjs
+++ b/build/ast.mjs
@@ -3,14 +3,17 @@ import { remark } from 'remark'
import gfm from 'remark-gfm'
import FS from 'fs-extra'
-const getHeadingText = (arr = [], title = '') => {
+const getHeadingText = (arr = []) => {
+ let title = ''
arr.forEach(child => {
- title += child.value
+ if (typeof child.value === 'string') {
+ title += child.value
+ }
if (child.children && Array.isArray(child.children)) {
- title += getHeadingText(child.children, title)
+ title += getHeadingText(child.children)
}
})
- return title;
+ return title
}
const getSoftwareName = (obj, result = { title: '' }) => {
@@ -132,4 +135,4 @@ remark()
FS.outputJsonSync('./dist/awesome-mac.zh.json', dataAST)
console.log(' create file: \x1b[32;1m ./dist/awesome-mac.zh.json \x1b[0m');
})
- .processSync(toVFile.readSync('README-zh.md'))
\ No newline at end of file
+ .processSync(toVFile.readSync('README-zh.md'))