|
1 | 1 | const fs = require('fs');
|
2 | 2 | const path = require('path');
|
3 | 3 | const webpack = require('webpack');
|
4 |
| -const FrontMatter = require('front-matter'); |
5 | 4 | const CleanPlugin = require('clean-webpack-plugin');
|
6 | 5 | const CopyWebpackPlugin = require('copy-webpack-plugin');
|
7 | 6 | const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
8 | 7 | const DirectoryTreePlugin = require('directory-tree-webpack-plugin');
|
| 8 | +const treePluginEnhacer = require('./src/utils/treePluginEnhacer.js'); |
9 | 9 |
|
10 | 10 | module.exports = (env = {}) => ({
|
11 | 11 | devtool: 'source-map',
|
@@ -109,25 +109,7 @@ module.exports = (env = {}) => ({
|
109 | 109 | dir: 'src/content',
|
110 | 110 | path: 'src/_content.json',
|
111 | 111 | extensions: /\.md/,
|
112 |
| - enhance: (item, options) => { |
113 |
| - item.url = item.path |
114 |
| - .replace(item.extension, '') |
115 |
| - .replace(options.dir, '') |
116 |
| - .replace(/\/index$/, '') |
117 |
| - .replace(/^$/, '/'); |
118 |
| - |
119 |
| - if (item.type === 'file') { |
120 |
| - // remove underscore from fetched files |
121 |
| - if (item.name[0] === '_') { |
122 |
| - item.name = item.name.replace('_', ''); |
123 |
| - item.url = item.url.replace('_', ''); |
124 |
| - } |
125 |
| - let content = fs.readFileSync(item.path, 'utf8'); |
126 |
| - let { attributes } = FrontMatter(content); |
127 |
| - Object.assign(item, attributes); |
128 |
| - item.anchors = []; // TODO: Add actual anchors |
129 |
| - } |
130 |
| - } |
| 112 | + enhance: treePluginEnhacer |
131 | 113 | })
|
132 | 114 | ],
|
133 | 115 | stats: {
|
|
0 commit comments