Add pathmap generation
This commit is contained in:
13
lib/guide.js
13
lib/guide.js
@@ -6,18 +6,15 @@ export const getRequestedGuide = req => {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Remove any slashes from the beginning
|
||||
// Webpack module resolver takes care of the base path
|
||||
// Look at `config.resolve.modules` in next.config.js
|
||||
// Remove `.md` from the end
|
||||
// We need to put that in `require` below to make
|
||||
// webpack bundle all the markdown files
|
||||
const path = guide.path.replace(/^\//, '').replace(/\.md$/, '');
|
||||
// We will use this URL format to find the relevant markdown
|
||||
// file inside the `/data` directory. For example `/guides/learn-regex`
|
||||
// has to have `/guides/learn-regex.md` file inside the `data` directory
|
||||
const path = guide.slug.replace(/^\//, '');
|
||||
|
||||
try {
|
||||
return {
|
||||
...guide,
|
||||
component: require(`../${path}.md`).default,
|
||||
component: require(`../data/${path}.md`).default,
|
||||
// component: require(guide.path.replace(/^\//, '')).default
|
||||
};
|
||||
} catch (e) {
|
||||
|
Reference in New Issue
Block a user