|
|
@@ -36,33 +36,24 @@ const _arrangeByMaterial = artistsList => {
|
|
36
|
36
|
return flatPacked
|
|
37
|
37
|
}
|
|
38
|
38
|
|
|
|
39
|
+let seenTitles = []
|
|
39
|
40
|
const _arrangeByAlpha = artistsList => {
|
|
40
|
41
|
const alphabet = [...'9abcdefghijklmnopqrstuvwxyz']
|
|
41
|
42
|
const flatPacked = []
|
|
42
|
|
- let seen = 0
|
|
43
|
|
- let hasTitle = []
|
|
44
|
43
|
|
|
45
|
44
|
const storeTitle = letter => {
|
|
46
|
|
- if(hasTitle.includes(letter)) return
|
|
|
45
|
+ if(seenTitles.includes(letter)) return
|
|
47
|
46
|
flatPacked.push({ slug: letter, title: letter, inbetween: true })
|
|
48
|
|
- hasTitle.push(letter)
|
|
|
47
|
+ seenTitles.push(letter)
|
|
49
|
48
|
}
|
|
50
|
49
|
|
|
51
|
|
- artistsList.forEach((artist, i) => {
|
|
|
50
|
+ artistsList.forEach(artist => {
|
|
52
|
51
|
const lastWord = artist.slug.split('-').filter(c => c).pop()
|
|
|
52
|
+ const firstCharaOflastWord = lastWord[0]
|
|
53
|
53
|
const firstCharaOfSortWord = artist.sortname ? artist.sortname[0] : 'z'
|
|
54
|
|
- const charaIndex = alphabet.indexOf(lastWord[0]) < alphabet.indexOf(firstCharaOfSortWord) ? alphabet.indexOf(lastWord[0]) : alphabet.indexOf(firstCharaOfSortWord)
|
|
55
|
|
-
|
|
56
|
|
- // The first artist you've seen in THIS BATCH
|
|
57
|
|
- if(i == 0) {
|
|
58
|
|
- seen = charaIndex
|
|
59
|
|
- storeTitle(alphabet[seen])
|
|
60
|
|
- }
|
|
61
|
|
- if (charaIndex == seen + 1) {
|
|
62
|
|
- seen++
|
|
63
|
|
- if(seen > alphabet.length) seen = 0
|
|
64
|
|
- storeTitle(alphabet[seen])
|
|
65
|
|
- }
|
|
|
54
|
+ const charaIndex = alphabet.indexOf(firstCharaOflastWord) < alphabet.indexOf(firstCharaOfSortWord) ? alphabet.indexOf(firstCharaOflastWord) : alphabet.indexOf(firstCharaOfSortWord)
|
|
|
55
|
+
|
|
|
56
|
+ storeTitle(alphabet[charaIndex])
|
|
66
|
57
|
flatPacked.push(artist)
|
|
67
|
58
|
})
|
|
68
|
59
|
return flatPacked
|