@@ -15,7 +15,7 @@ function getDocPageForId(id: string): docPage {
15
15
return {
16
16
title : title ,
17
17
id : id ,
18
- frontmatter : {
18
+ frontMatter : {
19
19
title : title ,
20
20
description : "Provides information on Teleport functionality" ,
21
21
} ,
@@ -510,7 +510,7 @@ describe("orderSidebarItems", () => {
510
510
"page-a" : {
511
511
title : "Page A" ,
512
512
id : "page-a" ,
513
- frontmatter : {
513
+ frontMatter : {
514
514
title : "Page A" ,
515
515
description : "Page A" ,
516
516
} ,
@@ -520,7 +520,7 @@ describe("orderSidebarItems", () => {
520
520
"page-b" : {
521
521
title : "Page B" ,
522
522
id : "page-b" ,
523
- frontmatter : {
523
+ frontMatter : {
524
524
title : "Page B" ,
525
525
description : "Page B" ,
526
526
} ,
@@ -530,7 +530,7 @@ describe("orderSidebarItems", () => {
530
530
"page-c" : {
531
531
title : "Page C" ,
532
532
id : "page-c" ,
533
- frontmatter : {
533
+ frontMatter : {
534
534
title : "Page C" ,
535
535
description : "Page C" ,
536
536
} ,
@@ -540,7 +540,7 @@ describe("orderSidebarItems", () => {
540
540
"page-d" : {
541
541
title : "Introduction" ,
542
542
id : "page-d" ,
543
- frontmatter : {
543
+ frontMatter : {
544
544
title : "Introduction" ,
545
545
description : "Introduction" ,
546
546
} ,
@@ -550,7 +550,7 @@ describe("orderSidebarItems", () => {
550
550
"page-e" : {
551
551
title : "Page E" ,
552
552
id : "page-e" ,
553
- frontmatter : {
553
+ frontMatter : {
554
554
title : "Page E" ,
555
555
description : "Page E" ,
556
556
sidebar_position : 2 ,
@@ -562,7 +562,7 @@ describe("orderSidebarItems", () => {
562
562
"page-f" : {
563
563
title : "Getting Started" ,
564
564
id : "page-f" ,
565
- frontmatter : {
565
+ frontMatter : {
566
566
title : "Getting Started" ,
567
567
description : "Getting Started" ,
568
568
} ,
@@ -572,7 +572,7 @@ describe("orderSidebarItems", () => {
572
572
"page-g" : {
573
573
title : "Introduction" ,
574
574
id : "page-g" ,
575
- frontmatter : {
575
+ frontMatter : {
576
576
title : "Introduction" ,
577
577
description : "Introduction" ,
578
578
} ,
@@ -760,12 +760,162 @@ describe("orderSidebarItems", () => {
760
760
} ) ;
761
761
} ) ;
762
762
763
+ describe ( "sidebar label" , ( ) => {
764
+ const idToDocPage = {
765
+ "page-a" : {
766
+ title : "Page A" ,
767
+ id : "page-a" ,
768
+ frontMatter : {
769
+ title : "Page A" ,
770
+ sidebar_label : "Page Z" ,
771
+ description : "Page A" ,
772
+ } ,
773
+ source : "@site/docs/page-a.mdx" ,
774
+ sourceDirName : "" ,
775
+ } ,
776
+ "page-b" : {
777
+ title : "Page B" ,
778
+ id : "page-b" ,
779
+ frontMatter : {
780
+ title : "Page B" ,
781
+ sidebar_label : "Page W" ,
782
+ description : "Page B" ,
783
+ } ,
784
+ source : "@site/docs/page-b.mdx" ,
785
+ sourceDirName : "" ,
786
+ } ,
787
+ "page-c" : {
788
+ title : "Page C" ,
789
+ id : "page-c" ,
790
+ frontMatter : {
791
+ title : "Page C" ,
792
+ sidebar_label : "Page X" ,
793
+ description : "Page C" ,
794
+ } ,
795
+ source : "@site/docs/page-c.mdx" ,
796
+ sourceDirName : "" ,
797
+ } ,
798
+ "page-d" : {
799
+ title : "Page D" ,
800
+ id : "page-d" ,
801
+ frontMatter : {
802
+ title : "Page D" ,
803
+ description : "Page D" ,
804
+ } ,
805
+ source : "@site/docs/page-d.mdx" ,
806
+ sourceDirName : "" ,
807
+ } ,
808
+ } ;
809
+
810
+ interface testCase {
811
+ description : string ;
812
+ input : Array < NormalizedSidebarItem > ;
813
+ expected : Array < NormalizedSidebarItem > ;
814
+ }
815
+
816
+ const testCases : Array < testCase > = [
817
+ {
818
+ description : "all pages use sidebar_label" ,
819
+ input : [
820
+ {
821
+ type : "category" ,
822
+ label : "My Docs Category" ,
823
+ items : [
824
+ {
825
+ type : "doc" ,
826
+ id : "page-a" ,
827
+ } ,
828
+ {
829
+ type : "doc" ,
830
+ id : "page-b" ,
831
+ } ,
832
+ {
833
+ type : "doc" ,
834
+ id : "page-c" ,
835
+ } ,
836
+ ] ,
837
+ } ,
838
+ ] ,
839
+ expected : [
840
+ {
841
+ type : "category" ,
842
+ label : "My Docs Category" ,
843
+ items : [
844
+ {
845
+ type : "doc" ,
846
+ id : "page-b" ,
847
+ } ,
848
+ {
849
+ type : "doc" ,
850
+ id : "page-c" ,
851
+ } ,
852
+ {
853
+ type : "doc" ,
854
+ id : "page-a" ,
855
+ } ,
856
+ ] ,
857
+ } ,
858
+ ] ,
859
+ } ,
860
+ {
861
+ description : "one page uses title" ,
862
+ input : [
863
+ {
864
+ type : "category" ,
865
+ label : "My Docs Category" ,
866
+ items : [
867
+ {
868
+ type : "doc" ,
869
+ id : "page-d" ,
870
+ } ,
871
+ {
872
+ type : "doc" ,
873
+ id : "page-b" ,
874
+ } ,
875
+ {
876
+ type : "doc" ,
877
+ id : "page-c" ,
878
+ } ,
879
+ ] ,
880
+ } ,
881
+ ] ,
882
+ expected : [
883
+ {
884
+ type : "category" ,
885
+ label : "My Docs Category" ,
886
+ items : [
887
+ {
888
+ type : "doc" ,
889
+ id : "page-d" ,
890
+ } ,
891
+ {
892
+ type : "doc" ,
893
+ id : "page-b" ,
894
+ } ,
895
+ {
896
+ type : "doc" ,
897
+ id : "page-c" ,
898
+ } ,
899
+ ] ,
900
+ } ,
901
+ ] ,
902
+ } ,
903
+ ] ;
904
+
905
+ test . each ( testCases ) ( "$description" , ( c ) => {
906
+ const actual = orderSidebarItems ( c . input , ( id : string ) : docPage => {
907
+ return idToDocPage [ id ] ;
908
+ } ) ;
909
+ expect ( actual ) . toEqual ( c . expected ) ;
910
+ } ) ;
911
+ } ) ;
912
+
763
913
describe ( "ordering category index pages" , ( ) => {
764
914
const idToDocPage = {
765
915
"section-a/section-a" : {
766
916
title : "Section A" ,
767
917
id : "section-a/section-a" ,
768
- frontmatter : {
918
+ frontMatter : {
769
919
title : "Section A" ,
770
920
description : "Section A" ,
771
921
} ,
@@ -775,7 +925,7 @@ describe("orderSidebarItems", () => {
775
925
"section-a/page-a" : {
776
926
title : "Section A Page A" ,
777
927
id : "section-a/page-a" ,
778
- frontmatter : {
928
+ frontMatter : {
779
929
title : "Section A Page A" ,
780
930
description : "Page A" ,
781
931
} ,
@@ -785,7 +935,7 @@ describe("orderSidebarItems", () => {
785
935
"section-a/page-b" : {
786
936
title : "Section A Page B" ,
787
937
id : "section-a/page-b" ,
788
- frontmatter : {
938
+ frontMatter : {
789
939
title : "Section A Page B" ,
790
940
description : "Page B" ,
791
941
} ,
@@ -795,7 +945,7 @@ describe("orderSidebarItems", () => {
795
945
"section-b/section-b" : {
796
946
title : "Section B" ,
797
947
id : "section-b/section-b" ,
798
- frontmatter : {
948
+ frontMatter : {
799
949
title : "Section B" ,
800
950
description : "Section B" ,
801
951
} ,
@@ -806,7 +956,7 @@ describe("orderSidebarItems", () => {
806
956
"section-b/page-a" : {
807
957
title : "Section B Page A" ,
808
958
id : "section-b/page-a" ,
809
- frontmatter : {
959
+ frontMatter : {
810
960
title : "Section B Page A" ,
811
961
description : "Page A" ,
812
962
} ,
@@ -817,7 +967,7 @@ describe("orderSidebarItems", () => {
817
967
"section-b/page-b" : {
818
968
title : "Section B Page B" ,
819
969
id : "section-b/page-b" ,
820
- frontmatter : {
970
+ frontMatter : {
821
971
title : "Section B Page B" ,
822
972
description : "Page B" ,
823
973
} ,
@@ -827,7 +977,7 @@ describe("orderSidebarItems", () => {
827
977
intro : {
828
978
title : "Introduction" ,
829
979
id : "intro" ,
830
- frontmatter : {
980
+ frontMatter : {
831
981
title : "Introduction" ,
832
982
description : "Introduction" ,
833
983
} ,
@@ -936,7 +1086,7 @@ describe("orderSidebarItems", () => {
936
1086
"page-a" : {
937
1087
title : "Page A" ,
938
1088
id : "page-a" ,
939
- frontmatter : {
1089
+ frontMatter : {
940
1090
title : "Page A" ,
941
1091
description : "Page A" ,
942
1092
} ,
@@ -947,7 +1097,7 @@ describe("orderSidebarItems", () => {
947
1097
"page-b" : {
948
1098
title : "Page B" ,
949
1099
id : "page-b" ,
950
- frontmatter : {
1100
+ frontMatter : {
951
1101
title : "Page B" ,
952
1102
description : "Page B" ,
953
1103
} ,
@@ -988,7 +1138,7 @@ describe("orderSidebarItems", () => {
988
1138
"page-a" : {
989
1139
title : "Page A" ,
990
1140
id : "page-a" ,
991
- frontmatter : {
1141
+ frontMatter : {
992
1142
title : "Page A" ,
993
1143
description : "Page A" ,
994
1144
} ,
@@ -999,7 +1149,7 @@ describe("orderSidebarItems", () => {
999
1149
"page-b" : {
1000
1150
title : "Page B" ,
1001
1151
id : "page-b" ,
1002
- frontmatter : {
1152
+ frontMatter : {
1003
1153
title : "Page B" ,
1004
1154
description : "Page B" ,
1005
1155
} ,
0 commit comments