-
Notifications
You must be signed in to change notification settings - Fork 2
/
script.js
28 lines (24 loc) · 1.04 KB
/
script.js
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
function getInterestingFields(content) {
return {
headline: content.fields.headline,
trailText: content.fields.trailText,
mainImage: content.fields.thumbnail,
};
}
function addRowOfNews(rowSubject, numberOfItems) {
var contentApiQuery = encodeURIComponent(rowSubject);
return addContentList(
rowSubject,
"http://content.guardianapis.com/search?q=" + contentApiQuery,
numberOfItems
);
}
// This adds the top 3 articles from a content api search. Try changing "Technology" to something else.
addRowOfNews("Technology", 3);
addRowOfNews("Greta Thunberg", 3);
// You could use the block below to add specific stories rather than just the top 3 from a certain topic
// addContentItems("Selected News", [
// "https://content.guardianapis.com/lifeandstyle/2015/oct/02/are-these-the-10-worst-board-games-of-all-time",
// "https://content.guardianapis.com/education/2016/mar/27/tom-bennett-behaviour-schools-teaching-hunger-games",
// "https://content.guardianapis.com/food/2019/jun/14/how-to-eat-chocolate-brownies"
// ])