UNPKG

734 BJavaScriptView Raw
1const fs = require('fs');
2const path = require('path');
3const walk = require('walk');
4const config = require('./config');
5const md = require('./lib/marked');
6const yamlFront = require('yaml-front-matter')
7
8
9const walker = walk.walk(config.root);
10walker.on('file', function (root, fileStats, next) {
11 const basename = fileStats.name;
12 const ext = path.extname(basename);
13
14 const file = path.resolve(__dirname, root + '/' + basename);
15 // console.log(file);
16 if (ext === '.md') {
17 const txt = fs.readFileSync(file, 'utf-8');
18 const res = md(txt);
19 console.log(res);
20 }
21
22 next();
23});
24
25
26walker.on('end', () => {
27
28 // console.log('end');
29});
30
31walker.on('error', (e) => {
32 console.log(e);
33})
\No newline at end of file