git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 45eb38ea158546001d22126e5b308ea80452483a

Files: 45eb38ea158546001d22126e5b308ea80452483a / modules / profile / html / manyPeople.js

1072 bytesRaw
1var nest = require('depnest')
2
3exports.needs = nest({
4 'profile.html.person': 'first'
5})
6
7exports.gives = nest({
8 'profile.html': [ 'manyPeople' ]
9})
10
11exports.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