Files
developer-roadmap/lib/guide.js

35 lines
798 B
JavaScript
Raw Normal View History

2020-01-18 22:47:48 +04:00
import guides from 'content/guides';
import authors from 'content/authors';
import siteConfig from 'content/site';
2019-11-06 22:10:25 +04:00
2019-11-08 18:57:57 +04:00
export const getAllGuides = () => {
2019-11-13 21:54:31 +04:00
return guides.filter(guide => !guide.draft)
.sort((a, b) => new Date(b.updatedAt) - new Date(a.updatedAt));
};
export const getFeaturedGuides = () => {
return getAllGuides().filter(guide => guide.featured);
2019-11-08 18:57:57 +04:00
};
export const getRequestedGuide = req => {
const guide = guides.find(guide => guide.url === req.url);
if (!guide) {
return null;
}
try {
return {
...guide,
2019-11-06 22:10:25 +04:00
author: authors.find(author => author.username === guide.author) || {},
};
} 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
};