-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathpaths.js
More file actions
51 lines (47 loc) · 1004 Bytes
/
paths.js
File metadata and controls
51 lines (47 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
var paths = {
'/': {
title: 'Home',
page: 'home.html'
},
'/about': {
title: 'About',
page: 'about.html'
},
'/blog': {
title: 'Blog'
},
posts: {
first_post: {
title: 'My First Blog Post',
md: 'first_post.md',
published: '2015-01-01',
preview: 'Everyone has to start somewhere.'
},
second_post: {
title: 'I Blogged Again',
md: 'blogged_again.md',
published: '2015-01-03',
preview: 'Oops I did it again.'
}
}
};
module.exports = {
allPaths: function() {
return paths;
},
allPosts: function() {
return paths.posts;
},
pageForPath: function(path) {
return this.pageReq()('./' + paths[path].page);
},
postForPath: function(path) {
return this.postReq()('./' + paths.posts[path].md);
},
pageReq: function() {
return require.context('./pages', false, /^\.\/.*\.html$/);
},
postReq: function() {
return require.context('./posts', false, /^\.\/.*\.md$/);
}
};