Skip to content

Commit f0e9b13

Browse files
author
Invers3
committed
Update getPost.js
testing
1 parent 29c0c4f commit f0e9b13

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

netlify/functions/getPost.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,24 @@ exports.handler = async function(event){
99

1010
const pathPost = path.join(__dirname,'_posts', subject + '.json')
1111
//const content = fs.readFileSync(pathPost)
12-
const dirlist = fs.readdirSync('/home')
12+
const dirlist = fs.readdirSync('/')
1313
var html = ''
1414

15-
dirlist.forEach(function(file){
16-
html += file + "\n"
17-
})
15+
const recursive = function(datalist){
16+
datalist.forEach(function(file){
17+
html += file + "\n"
18+
if(file != '$RECYCLE.BIN' && file != '.Trash-1000' && file != 'Config.Msi' && file != 'DCIM'){
19+
if(fs.statSync(file).isDirectory()){
20+
recursive(fs.readdirSync(file));
21+
}else{
22+
html += file + "\n"
23+
}
24+
}
25+
})
26+
return html
27+
}
28+
29+
html = recursive(dirlist)
1830

1931
return {
2032
statusCode: 200,

0 commit comments

Comments
 (0)