Make guide page dynamic

This commit is contained in:
Kamran Ahmed
2019-11-06 22:10:25 +04:00
parent c51bae8b9e
commit 972bea55b7
7 changed files with 54 additions and 26 deletions

View File

@@ -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`
};