Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Jul 8, 2023. It is now read-only.
forked from sjaakvandenberg/devgroups
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeed.js
More file actions
Latest commit
58 lines (50 loc) · 1.79 KB
/
Copy pathfeed.js
File metadata and controls
58 lines (50 loc) · 1.79 KB
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
module.exports=function(){
varharp=require("./harp.json")["globals"]
,RSS=require("rss")
,moment=require("moment")
,fs=require("fs")
,rootUrl=harp.root_url[process.env.NODE_ENV]
,imageRootUrl=rootUrl+"assets/images/"
,outputFeed="public/rss.xml"
,devgroups=[]
;
varfeed=newRSS({
title: harp.title,
description: harp.description,
feed_url: rootUrl+"rss.xml",
site_url: rootUrl,
image_url: imageRootUrl+"devgroups-128.png",
managingEditor: harp.author,
pubDate: moment().format("LLLL"),
ttl: 60
});
harp.platforms.forEach(function(platformName){
varplatform=require("./public/"+platformName+"/_data.json")["index"];
platform.devgroups.forEach(function(devgroup){
vardevgroupId=devgroup.title.replace(/[^\w\s]/g,"").replace(/\s/g,"-").toLowerCase();
vardevgroupLink=rootUrl+platformName+"/#"+devgroupId;
vardevgroupPublishedAt=moment(devgroup.published_at||moment().format("YYYYMMDD"),"YYYYMMDD");
vardevgroupImage=imageRootUrl+(devgroup.image||platform.image);
devgroups.push({
title: "DevGroup: "+devgroup.title,
description: devgroup.description,
url: devgroupLink,
author: harp.author,
date: devgroupPublishedAt.format("ll"),
enclosure: {
url: devgroupImage
}
});
});
});
varsortedDevGroups=devgroups.sort(function(a,b){
vara=moment(a.date,"ll").toDate().getTime();
varb=moment(b.date,"ll").toDate().getTime();
if(a<b)return1;
if(a>b)return-1;
return0;
});
sortedDevGroups.forEach(function(devgroup){feed.item(devgroup);});
fs.writeFileSync(outputFeed,feed.xml());
console.log("Generated RSS:",outputFeed);
};