UNPKG

829 BJavaScriptView Raw
1'use strict';
2
3const capiV2 = require('./utils/capi-v2');
4
5module.exports = function (opts) {
6 let by = opts.by;
7 if (!by && opts.uuid) {
8 by = 'http://api.ft.com/things/' + opts.uuid;
9 }
10
11 const count = opts.count || 10;
12 return capiV2({
13 path: '/content?isAnnotatedBy=' + by
14 + (opts.authority ? '&authority=' + opts.authority : '')
15 + (opts.bindings ? '&bindings=' + opts.authority : ''),
16 type: 'ContentAnnotatedBy'
17 })
18 .then(function (articles) {
19 // NOTE: endpoint will change to just return an array
20 const items = Array.isArray(articles) ? articles : articles.content;
21 return items.slice(0, count).map(function (article) {
22 return article.apiUrl.replace('http://api.ft.com/content/', '');
23 });
24 })
25 .then(function (articles) {
26 articles.indexCount = articles.length;
27 return articles;
28 });
29};