2019-11-06 18:20:09 +04:00
|
|
|
import guides from "data/guides";
|
2019-11-06 22:10:25 +04:00
|
|
|
import authors from "data/authors";
|
|
|
|
import siteConfig from "data/site";
|
|
|
|
|
2019-11-06 18:20:09 +04:00
|
|
|
export const getRequestedGuide = req => {
|
2019-11-06 21:37:16 +04:00
|
|
|
const guide = guides.find(guide => guide.url === req.url);
|
2019-11-06 18:20:09 +04:00
|
|
|
if (!guide) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
return {
|
|
|
|
...guide,
|
2019-11-06 22:10:25 +04:00
|
|
|
author: authors.find(author => author.username === guide.author) || {},
|
2019-11-06 18:20:09 +04:00
|
|
|
};
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|
2019-11-06 22:10:25 +04:00
|
|
|
|
|
|
|
export const getContributionUrl = (guide) => {
|
2019-11-08 16:47:21 +04:00
|
|
|
return `${siteConfig.url.repoData}${guide.url}.md`
|
2019-11-06 22:10:25 +04:00
|
|
|
};
|