Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3484aa9

Browse files
feat: add database/shell reg
1 parent 35e81e2 commit 3484aa9

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

‎main.js‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,21 @@ const isEn = () => location.hash.includes('README_EN');
22

33
const isRoot = () => ['', '#/', '#/README', '#/README_EN'].includes(location.hash);
44

5-
const isJavascript = /^#\/javascript_solution\/.*$/.test(location.hash);
5+
const isJavascript = () => /^#\/javascript_solution\/.*$/.test(location.hash);
6+
7+
const isDatabase = () => /^#\/database_solution\/.*$/.test(location.hash);
8+
9+
const isShell = () => /^#\/shell_solution\/.*$/.test(location.hash);
610

711
const sidebar = () => {
812
if (isRoot()) {
913
return false;
1014
}
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()) {
1220
return isEn() ? 'javascript_summary_en.md' : 'javascript_summary.md';
1321
}
1422
return isEn() ? 'summary_en.md' : 'summary.md';
@@ -21,7 +29,15 @@ const cleanedHtml = html => {
2129
};
2230

2331
const replaceHref = html => {
24-
return html.replace(/\/solution\//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(/\/solution\//g, `/${res}/`) : html;
2541
};
2642

2743
const getLang = () => (isEn() ? 'en' : 'zh-CN');
@@ -69,6 +85,8 @@ window.$docsify = {
6985
subMaxLevel: 2,
7086
alias: {
7187
'^/javascript_solution/(.*)': '/solution/1ドル',
88+
'^/shell_solution/(.*)': '/solution/1ドル',
89+
'^/database_solution/(.*)': '/solution/1ドル',
7290
'/lcs/.*/summary.md': '/lcs/summary.md',
7391
'/lcp/.*/summary.md': '/lcp/summary.md',
7492
'/lcci/.*/summary.md': '/lcci/summary.md',
@@ -147,9 +165,7 @@ window.$docsify = {
147165
const github = `[GitHub](${url})`;
148166
const gitee = `[Gitee](${url.replace('github', 'gitee')})`;
149167
html = cleanedHtml(html);
150-
if (isJavascript) {
151-
html = replaceHref(html);
152-
}
168+
html = replaceHref(html);
153169
const editHtml = isEn()
154170
? `:memo: Edit on ${github} / ${gitee}\n`
155171
: `:memo: 在 ${github} / ${gitee} 编辑\n`;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /