Restructure routes, add tests and make pathmap dynamic

This commit is contained in:
Kamran Ahmed
2019-11-06 21:37:16 +04:00
parent 159741f0af
commit 796f1cdac0
23 changed files with 1798 additions and 99 deletions

View File

@@ -1,7 +1,7 @@
import guides from "data/guides";
export const getRequestedGuide = req => {
const guide = guides.find(guide => guide.slug === req.url);
const guide = guides.find(guide => guide.url === req.url);
if (!guide) {
return null;
}
@@ -9,7 +9,7 @@ export const getRequestedGuide = req => {
// 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(/^\//, '');
const path = guide.url.replace(/^\//, '');
try {
return {