Files: bcadbcc3325b20b2d11e736b46940303044e756c / modules / profile / html / manyPeople.js
1072 bytesRaw
1 | var nest = require('depnest') |
2 | |
3 | exports.needs = nest({ |
4 | 'profile.html.person': 'first' |
5 | }) |
6 | |
7 | exports.gives = nest({ |
8 | 'profile.html': [ 'manyPeople' ] |
9 | }) |
10 | |
11 | exports.create = function (api) { |
12 | return nest({ |
13 | 'profile.html': { manyPeople } |
14 | }) |
15 | |
16 | function manyPeople (ids) { |
17 | ids = Array.from(ids) |
18 | var featuredIds = ids.slice(-3).reverse() |
19 | |
20 | if (ids.length) { |
21 | if (ids.length > 3) { |
22 | return [ |
23 | api.profile.html.person(featuredIds[0]), ', ', |
24 | api.profile.html.person(featuredIds[1]), |
25 | ' and ', ids.length - 2, ' others' |
26 | ] |
27 | } else if (ids.length === 3) { |
28 | return [ |
29 | api.profile.html.person(featuredIds[0]), ', ', |
30 | api.profile.html.person(featuredIds[1]), ' and ', |
31 | api.profile.html.person(featuredIds[2]) |
32 | ] |
33 | } else if (ids.length === 2) { |
34 | return [ |
35 | api.profile.html.person(featuredIds[0]), ' and ', |
36 | api.profile.html.person(featuredIds[1]) |
37 | ] |
38 | } else { |
39 | return api.profile.html.person(featuredIds[0]) |
40 | } |
41 | } |
42 | } |
43 | } |
44 |
Built with git-ssb-web