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