on master help sign in
address review comments
fcab19eckipp01
scripts/portal.js+3−6
@@ -13,8 +13,7 @@ function Portal (sites) {
13 function _directory (sites) {
13 function _directory (sites) {
14 const siteTypesArray = [...new Set(sites.map(site => site.type).filter(Boolean))]
14 const siteTypesArray = [...new Set(sites.map(site => site.type).filter(Boolean))]
15 const siteLangsArray = [...new Set(sites
15 const siteLangsArray = [...new Set(sites
16− .map(site => site.langs)
17− .reduce((flattened, langs) => flattened.concat(langs), [])
16+ .reduce((flattened, site) => flattened.concat(site.langs), [])
18 .sort())]
17 .sort())]
19
18
20 const siteTypes = siteTypesArray.reduce((output, siteType) =>
19 const siteTypes = siteTypesArray.reduce((output, siteType) =>
@@ -39,8 +38,7 @@ function Portal (sites) {
39 }
38 }
40
39
41 function _lang (site) {
40 function _lang (site) {
42− const langs = site.langs.reduce((langs, lang) => `${langs} ${lang}`, '')
43− return `data-lang="${langs.trim()}"`
41+ return `data-lang="${site.langs.join(' ').trim()}"`
44 }
42 }
45
43
46 function _redirectView (site) {
44 function _redirectView (site) {
@@ -73,8 +71,7 @@ function Portal (sites) {
73 }
71 }
74
72
75 this.sitesMatchingLangs = this.sites
73 this.sitesMatchingLangs = this.sites
76− .filter(site => site.langs)
77− .filter(site => site.langs.some(lang => navigator.languages.includes(lang)))
74+ .filter(site => site.langs && site.langs.some(lang => navigator.languages.includes(lang)))
78
75
79 this.next = function () {
76 this.next = function () {
80 const hash = window.location.hash.replace('#', '').trim()
77 const hash = window.location.hash.replace('#', '').trim()