Last active
October 5, 2017 13:45
-
-
Save simonwjackson/56fff7941db54c4afb7ff286b74ec401 to your computer and use it in GitHub Desktop.
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
// ;(function(options) { | |
command('reddit', 'reddit list', ([sub]) => { | |
if (!sub) sub = 'top' | |
else sub = `r/${sub}` | |
const subreddit = `https://www.reddit.com/${sub}.json?sort=top&t=day` | |
function reddit2list(json) { | |
return json.data.children.map(child => ({ | |
title: child.data.title.trim(), | |
url: child.data.url | |
})) | |
} | |
fetch(subreddit, { mode: 'cors' }) | |
.then(response => response.json()) | |
.then(reddit2list) | |
.then(items => { | |
Front.omnibar.show() | |
// Omnibar.listWords(words) | |
Omnibar.listResults(items, item => { | |
return $('<li/>') | |
.html(`<span class='title-icon'>📰</span> ${item.title}`) | |
.data('query', item.title) | |
.data('url', item.url) | |
}) | |
}) | |
}) | |
// })(options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment