Get a daily e-mail with any products that match your query
Created
January 28, 2016 16:04
-
-
Save rbren/538aba01413e5db4c823 to your computer and use it in GitHub Desktop.
Product Hunt Alerts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GET https://api.producthunt.com/v1/categories/{category}/posts | |
function request(data) { | |
return {category: constants.category || "tech"} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// POST https://datafire.io/services/mail/send | |
function request(data) { | |
var query = (constants.query || '').toLowerCase(); | |
var posts = data[0].posts.filter(function(post) { | |
var searchText = post.name.toLowerCase() + " " + post.tagline.toLowerCase(); | |
return searchText.indexOf(query) !== -1; | |
}) | |
if (!posts.length) return []; | |
var message = posts.map(function(post) { | |
return '<h2>' + post.name + '</h2>' + | |
'<h4>' + post.tagline + ' ' + | |
'<small><a href="' + post.discussion_url + '">View on Product Hunt</a></small></h4>' + | |
'<img src="' + post.thumbnail.image_url + '">'; | |
}).join('<br>'); | |
return { | |
body: { | |
to: constants.email, | |
subject: "Product Hunt - Today's Products " + (constants.query ? ("matching " + constants.query) : ""), | |
message: message, | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment