@@ -23,6 +23,9 @@ import (
2323
2424// TODO: post에 Thumnail 추가 -> header hero 처럼
2525
26+ // FIX: fixed된 게시물 이름순으로 하기. -> Q: 힙하게 힙하게 가 똑같으면 어떻게 비교를 수행하는가?
27+ // FIX: fixed, category 이름 순에 숫자->한글->영어 순으로 하기
28+
2629func main () {
2730 // Get env
2831 var appEnv string = os .Getenv ("APP_ENV" )
@@ -402,17 +405,10 @@ func main() {
402405 for category := range postsDataByCategory {
403406 categories = append (categories , category )
404407 }
405- sort .Slice (categories , func (i , j int ) bool {
406- keyI := categories [i ]
407- keyJ := categories [j ]
408- isKoreanI := lib .IsKorean (keyI )
409- isKoreanJ := lib .IsKorean (keyJ )
410-
411- if isKoreanI != isKoreanJ {
412- return isKoreanI
413- }
414408
415- return keyI < keyJ
409+ // 목록 Sort
410+ sort .Slice (categories , func (i , j int ) bool {
411+ return lib .CompareStrings (categories [i ], categories [j ])
416412 })
417413
418414 for _ , category := range categories {
@@ -429,7 +425,7 @@ func main() {
429425 postList = append (postList , fmt .Sprintf ("<h2 class=\" category-group-title\" ><a href=\" %s\" >[%s]</a></h2>" , categoryLink , category ))
430426 postList = append (postList , "<ul class=\" category-group-list\" >" )
431427
432- // 정렬: fixed, date
428+ // fixed 정렬
433429 sort .Slice (posts , func (i , j int ) bool {
434430 postI := posts [i ]
435431 postJ := posts [j ]
@@ -444,15 +440,7 @@ func main() {
444440 if fixedI {
445441 titleI , _ := postI ["title" ].(string )
446442 titleJ , _ := postJ ["title" ].(string )
447-
448- isKoreanI := lib .IsKorean (titleI )
449- isKoreanJ := lib .IsKorean (titleJ )
450-
451- if isKoreanI != isKoreanJ {
452- return isKoreanI
453- }
454-
455- return titleI < titleJ
443+ return lib .CompareStrings (titleI , titleJ )
456444 }
457445
458446 dateI , _ := postI ["date" ].(string )
@@ -570,6 +558,7 @@ func main() {
570558 return
571559 }
572560
561+ // 정렬
573562 for category , posts := range postsDataByCategory {
574563 sort .Slice (posts , func (i , j int ) bool {
575564 postI := posts [i ]
@@ -579,16 +568,13 @@ func main() {
579568 if fixedI != fixedJ {
580569 return fixedI
581570 }
571+
582572 if fixedI {
583573 titleI , _ := postI ["title" ].(string )
584574 titleJ , _ := postJ ["title" ].(string )
585- isKoreanI := lib .IsKorean (titleI )
586- isKoreanJ := lib .IsKorean (titleJ )
587- if isKoreanI != isKoreanJ {
588- return isKoreanI
589- }
590- return titleI < titleJ
575+ return lib .CompareStrings (titleI , titleJ )
591576 }
577+
592578 dateI , _ := postI ["date" ].(string )
593579 dateJ , _ := postJ ["date" ].(string )
594580 return dateI > dateJ
0 commit comments