UNPKG

awwwards

Version:
53 lines (37 loc) 1.22 kB
const Awwwards = require('./lib/awwwards'); const RSS = require('rss'); const express = require('express'); const app = express() const generate = (sites, title = 'Awwwards') => { let feed = new RSS({ title, description: 'The awards of design, creativity and innovation on the internet', site_url: 'https://awwwards.com/' }); for(let site of sites) { feed.item({ url: site.site, date: site.date, title: site.title, description: '<a href="' + site.link + '"><img src="' + site.image + '"></a>' + '<p>by <strong>' + site.author.name + '</strong> from ' + site.author.country + '</p>', categories: [site.category], author: site.author.name, }); } return feed.xml(); } app.get('/', (req, res) => { new Awwwards().then((sites) => { res.set('Content-Type', 'text/xml'); res.send(generate(sites)); }); }); app.get('/nominees', (req, res) => { Awwwards.nominees().then((sites) => { res.set('Content-Type', 'text/xml'); res.send(generate(sites, 'Nominees')); }); }); app.listen(process.argv[2] || 3000);