@@ -2,13 +2,21 @@ const isEn = () => location.hash.includes('README_EN');
2
2
3
3
const isRoot = ( ) => [ '' , '#/' , '#/README' , '#/README_EN' ] . includes ( location . hash ) ;
4
4
5
- const isJavascript = / ^ # \/ j a v a s c r i p t _ s o l u t i o n \/ .* $ / . test ( location . hash ) ;
5
+ const isJavascript = ( ) => / ^ # \/ j a v a s c r i p t _ s o l u t i o n \/ .* $ / . test ( location . hash ) ;
6
+
7
+ const isDatabase = ( ) => / ^ # \/ d a t a b a s e _ s o l u t i o n \/ .* $ / . test ( location . hash ) ;
8
+
9
+ const isShell = ( ) => / ^ # \/ s h e l l _ s o l u t i o n \/ .* $ / . test ( location . hash ) ;
6
10
7
11
const sidebar = ( ) => {
8
12
if ( isRoot ( ) ) {
9
13
return false ;
10
14
}
11
- if ( isJavascript ) {
15
+ if ( isJavascript ( ) ) {
16
+ return isEn ( ) ? 'javascript_summary_en.md' : 'javascript_summary.md' ;
17
+ } else if ( isDatabase ( ) ) {
18
+ return isEn ( ) ? 'javascript_summary_en.md' : 'javascript_summary.md' ;
19
+ } else if ( isShell ( ) ) {
12
20
return isEn ( ) ? 'javascript_summary_en.md' : 'javascript_summary.md' ;
13
21
}
14
22
return isEn ( ) ? 'summary_en.md' : 'summary.md' ;
@@ -21,7 +29,15 @@ const cleanedHtml = html => {
21
29
} ;
22
30
23
31
const replaceHref = html => {
24
- return html . replace ( / \/ s o l u t i o n \/ / g, '/javascript_solution/' ) ;
32
+ let res ;
33
+ if ( isJavascript ( ) ) {
34
+ res = 'javascript_solution' ;
35
+ } else if ( isDatabase ( ) ) {
36
+ res = 'database_solution' ;
37
+ } else if ( isShell ( ) ) {
38
+ res = 'shell_solution' ;
39
+ }
40
+ return res ? html . replace ( / \/ s o l u t i o n \/ / g, `/${ res } /` ) : html ;
25
41
} ;
26
42
27
43
const getLang = ( ) => ( isEn ( ) ? 'en' : 'zh-CN' ) ;
@@ -69,6 +85,8 @@ window.$docsify = {
69
85
subMaxLevel : 2 ,
70
86
alias : {
71
87
'^/javascript_solution/(.*)' : '/solution/$1' ,
88
+ '^/shell_solution/(.*)' : '/solution/$1' ,
89
+ '^/database_solution/(.*)' : '/solution/$1' ,
72
90
'/lcs/.*/summary.md' : '/lcs/summary.md' ,
73
91
'/lcp/.*/summary.md' : '/lcp/summary.md' ,
74
92
'/lcci/.*/summary.md' : '/lcci/summary.md' ,
@@ -147,9 +165,7 @@ window.$docsify = {
147
165
const github = `[GitHub](${ url } )` ;
148
166
const gitee = `[Gitee](${ url . replace ( 'github' , 'gitee' ) } )` ;
149
167
html = cleanedHtml ( html ) ;
150
- if ( isJavascript ) {
151
- html = replaceHref ( html ) ;
152
- }
168
+ html = replaceHref ( html ) ;
153
169
const editHtml = isEn ( )
154
170
? `:memo: Edit on ${ github } / ${ gitee } \n`
155
171
: `:memo: 在 ${ github } / ${ gitee } 编辑\n` ;
0 commit comments