|
|
@@ -56,13 +56,21 @@ const _arrangeByAlpha = (postsList, seenTitles) => {
|
|
56
|
56
|
const lastWord = post.slug.split('-').filter(c => c).pop()
|
|
57
|
57
|
const firstCharaOflastWord = lastWord[0]
|
|
58
|
58
|
const firstCharaOfSortWord = post.sortname ? post.sortname[0] : 'z'
|
|
59
|
|
- let charaIndex = alphabet.indexOf(firstCharaOflastWord) < alphabet.indexOf(firstCharaOfSortWord) ? alphabet.indexOf(firstCharaOflastWord) : alphabet.indexOf(firstCharaOfSortWord)
|
|
60
|
59
|
|
|
61
|
|
- // Kamaka problem
|
|
62
|
|
- if(seenTitles.includes(letter)) {
|
|
63
|
|
- charaIndex = alphabet.indexOf(firstCharaOflastWord) > alphabet.indexOf(firstCharaOfSortWord) ? alphabet.indexOf(firstCharaOflastWord) : alphabet.indexOf(firstCharaOfSortWord)
|
|
|
60
|
+ let charaIndex = null
|
|
|
61
|
+ let otherIndex = null
|
|
|
62
|
+ const lastWordAlphaIndex = alphabet.indexOf(firstCharaOflastWord)
|
|
|
63
|
+ const altWordAlphaIndex = alphabet.indexOf(firstCharaOfSortWord)
|
|
|
64
|
+ if(lastWordAlphaIndex < altWordAlphaIndex) {
|
|
|
65
|
+ charaIndex = lastWordAlphaIndex
|
|
|
66
|
+ otherIndex = altWordAlphaIndex
|
|
|
67
|
+ } else if (lastWordAlphaIndex > altWordAlphaIndex) {
|
|
|
68
|
+ otherIndex = lastWordAlphaIndex
|
|
|
69
|
+ charaIndex = altWordAlphaIndex
|
|
|
70
|
+ }
|
|
|
71
|
+ if(seenTitles.includes(alphabet[charaIndex])) {
|
|
|
72
|
+ charaIndex = otherIndex
|
|
64
|
73
|
}
|
|
65
|
|
-
|
|
66
|
74
|
storeTitle(alphabet[charaIndex])
|
|
67
|
75
|
flatPacked.push(post)
|
|
68
|
76
|
})
|