-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.js
57 lines (53 loc) · 1.48 KB
/
config.js
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
51
52
53
54
55
56
57
/*
|-------------------------------------------------------------------------------
| Development config https://maizzle.com/docs/environments
|-------------------------------------------------------------------------------
|
| The exported object contains the default Maizzle settings for development.
| This is used when you run `maizzle build` or `maizzle serve` and it has
| the fastest build time, since most transformations are disabled.
|
*/
const Parser = require('rss-parser')
module.exports = {
build: {
feed: {
url: 'https://laracasts.com/feed',
},
templates: {
source: 'src/templates',
destination: {
path: 'build_local',
},
assets: {
source: 'src/images',
destination: 'images'
}
},
},
events: {
async beforeCreate(config) {
// create a new Parser instance
const parser = new Parser({
customFields: {
feed: ['subtitle'],
item: ['summary'],
}
})
// fetch and parse the feed
const feed = await parser.parseURL(config.build.feed.url)
// store the feed data in our config
config.feed = {
title: feed.title,
subtitle: feed.subtitle,
link: feed.link,
updated_at: feed.lastBuildDate,
posts: feed.items,
}
}
},
formattedDate(str) {
const date = new Date(str)
return date.toLocaleDateString('en-US', {day: 'numeric', month: 'short', year: 'numeric'})
},
}