Make guide page dynamic
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import guides from "data/guides";
|
||||
import authors from "data/authors";
|
||||
import siteConfig from "data/site";
|
||||
|
||||
|
||||
export const getRequestedGuide = req => {
|
||||
const guide = guides.find(guide => guide.url === req.url);
|
||||
@@ -14,8 +17,8 @@ export const getRequestedGuide = req => {
|
||||
try {
|
||||
return {
|
||||
...guide,
|
||||
author: authors.find(author => author.username === guide.author) || {},
|
||||
component: require(`../data/${path}.md`).default,
|
||||
// component: require(guide.path.replace(/^\//, '')).default
|
||||
};
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
@@ -23,3 +26,7 @@ export const getRequestedGuide = req => {
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export const getContributionUrl = (guide) => {
|
||||
return `${siteConfig.repoUrl}${siteConfig.dataUrl}${guide.url}.md`
|
||||
};
|
||||
|
Reference in New Issue
Block a user