@@ -5,7 +5,16 @@ import React, { useEffect, useState } from "react";
5
5
import DocSidebar from '@theme/DocSidebar' ;
6
6
import styles from "@site/src/theme/Layout/styles.module.css"
7
7
import useDocusaurusContext from '@docusaurus/useDocusaurusContext' ;
8
- import * as capitalize from "lodash.capitalize"
8
+ import * as upperFirst from "lodash.upperfirst"
9
+ import { lineaSidebarNames } from "@site/src/lib/constants" ;
10
+
11
+ const formatMenuLabel = ( label ) => {
12
+ const menuItem = lineaSidebarNames . find ( name => name . old === label ) ;
13
+ if ( menuItem ) {
14
+ return menuItem . new ;
15
+ }
16
+ return label ;
17
+ }
9
18
10
19
function generateSidebarItems ( docs ) {
11
20
const categories = { } ;
@@ -15,22 +24,21 @@ function generateSidebarItems(docs) {
15
24
categories [ 'Introduction' ] = {
16
25
type : 'link' ,
17
26
href : '/services' ,
18
- label : capitalize ( doc . frontMatter ?. sidebar_label || doc . title ) ,
27
+ label : upperFirst ( doc . frontMatter ?. sidebar_label || doc . title ) ,
19
28
} ;
20
29
return ;
21
30
}
22
31
23
32
const pathParts = doc . sourceDirName . split ( '/' ) ;
24
33
let currentCategory = categories ;
25
34
let isIndexPage = doc . id . endsWith ( '/index' ) ;
26
-
27
- pathParts . forEach ( ( part , index ) => {
35
+ pathParts . map ( pathPart => formatMenuLabel ( pathPart ) ) . forEach ( ( part , index ) => {
28
36
if ( ! currentCategory [ part ] ) {
29
37
if ( isIndexPage && index === pathParts . length - 2 ) {
30
38
currentCategory [ part ] = {
31
39
type : 'category' ,
32
- label : capitalize ( doc . frontMatter ?. sidebar_label || doc . frontMatter ?. title || part ) ,
33
- collapsed : true ,
40
+ label : upperFirst ( doc . frontMatter ?. sidebar_label || doc . frontMatter ?. title || part ) ,
41
+ collapsed : false ,
34
42
collapsible : true ,
35
43
link : {
36
44
type : 'generated-index' ,
@@ -41,8 +49,8 @@ function generateSidebarItems(docs) {
41
49
} else {
42
50
currentCategory [ part ] = {
43
51
type : 'category' ,
44
- label : capitalize ( part ) ,
45
- collapsed : true ,
52
+ label : upperFirst ( part ) ,
53
+ collapsed : part !== "get-started" ,
46
54
collapsible : true ,
47
55
items : [ ]
48
56
} ;
@@ -52,7 +60,7 @@ function generateSidebarItems(docs) {
52
60
if ( index === pathParts . length - 1 && ! isIndexPage ) {
53
61
currentCategory [ part ] . items . push ( {
54
62
type : 'link' ,
55
- label : capitalize ( doc . frontMatter ?. title || doc . title ) ,
63
+ label : doc . frontMatter ?. title || doc . title ,
56
64
href : `/services/${ doc . id . replace ( / \/ i n d e x $ / , '' ) } ` ,
57
65
sidebar_position : doc . frontMatter ?. sidebar_position || Number . MAX_SAFE_INTEGER
58
66
} ) ;
@@ -88,7 +96,7 @@ const CustomPage = (props) => {
88
96
return {
89
97
...item ,
90
98
items : item . items . map ( referenceItem => {
91
- if ( referenceItem ?. label === capitalize ( NETWORK_NAMES . linea ) && referenceItem ?. items ) {
99
+ if ( referenceItem ?. label === upperFirst ( NETWORK_NAMES . linea ) && referenceItem ?. items ) {
92
100
return { ...referenceItem , items : [ ...referenceItem . items , ...siteConfig . customFields . dynamicData ] } ;
93
101
}
94
102
return referenceItem ;
0 commit comments