We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 88a7eaf commit a9dd135Copy full SHA for a9dd135
src/utils/treePluginEnhacer.js
@@ -0,0 +1,24 @@
1
+const fs = require('fs');
2
+const FrontMatter = require('front-matter');
3
+
4
+module.exports = function(item, options) {
5
+ item.url = item.path
6
+ .replace(item.extension, '')
7
+ .replace(options.dir, '')
8
+ .replace(/\/index$/, '')
9
+ .replace(/^$/, '/');
10
11
+ if (item.type === 'file') {
12
+ // remove underscore from fetched files
13
+ if (item.name[0] === '_') {
14
+ item.name = item.name.replace('_', '');
15
+ item.url = item.url.replace('_', '');
16
+ }
17
18
+ let content = fs.readFileSync(item.path, 'utf8');
19
+ let { attributes } = FrontMatter(content);
20
21
+ Object.assign(item, attributes);
22
+ item.anchors = []; // TODO: Add actual anchors
23
24
+}
0 commit comments