forked from KyleAMathews/blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post-build.coffee
64 lines (57 loc) · 1.61 KB
/
post-build.coffee
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
58
59
60
61
62
63
64
#Feed = require('feed')
#filter = require 'lodash/filter'
#sortBy = require 'lodash/sortBy'
#moment = require 'moment'
#MarkdownIt = require 'markdown-it'
#fs = require 'fs'
#frontmatter = require 'front-matter'
#md = MarkdownIt({
#html: true
#linkify: true
#typographer: true
#})
#module.exports = (pages, callback) ->
#generateAtomFeed(pages)
#callback()
#generateAtomFeed = (pages) ->
#feed = new Feed({
#title: 'Bricolage',
#description: 'A blog by Kyle Mathews',
#link: 'https://bricolage.io/',
#id: 'https://bricolage.io/',
#copyright: 'All rights reserved 2016, Kyle Mathews',
#author: {
#name: 'Kyle Mathews',
#email: '[email protected]',
#}
#})
## Sort by date.
#pages = sortBy(pages, (page) -> page.data?.date).reverse()
#for page in filter(pages, (f) ->
#f.data?.title? and not f.data?.draft
#).slice(0,10)
#feed.addItem({
#title: page.data.title
#id: "https://bricolage.io#{page.path}"
#link: "https://bricolage.io#{page.path}"
#date: moment(page.data.date).toDate()
#content: md.render(
#frontmatter(
#fs.readFileSync(
#"#{__dirname}/pages/#{page.requirePath}",
#'utf-8'
#)
#).body
#)
#author: [{
#name: "Kyle Mathews"
#email: "[email protected]"
#link: "https://bricolage.io"
#}]
#})
#feed.addContributor({
#name: 'Kyle Mathews'
#email: '[email protected]'
#link: 'https://bricolage.io'
#})
#fs.writeFileSync "#{__dirname}/public/atom.xml", feed.render('atom-1.0')