-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cjsx
executable file
·41 lines (28 loc) · 1.3 KB
/
main.cjsx
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
Entry = require './views/Entry.cjsx'
Home = require './views/Home.cjsx'
React = require 'react'
# Only necessary if providing a feed for Facebook Instant Articles.
{ fbInstantArticlesRSSFeed } = require 'proof-sdk/fb_instant_articles'
module.exports = ({ api, emitFile, emitRSS, done }) ->
Promise.all([
api.entries()
]).then ([entries]) ->
# A typical pattern is to first transform the incoming content objects,
# generating links, applying references. This is especially important
# when Packages and Entities are used, or when Entries reference other
# Entries.
entries.forEach (entry) ->
entry.link = "/stories/#{ entry.slug }/"
entry.full_link = "http://#{ config.HOST }#{ entry.link }"
# Once all the data is transformed, generate and emit the file content
# for each link.
entries.forEach (entry) ->
emitFile(entry.link, <Entry entry=entry />)
emitFile('/', <Home entries=entries />)
emitRSS('/fb_instant_feed.xml', fbInstantArticlesRSSFeed(
title: 'Instant Articles'
entries: entries
))
# Done MUST be called so the SDK can perform additional tasks, like
# uploading the files during a deployment.
done()