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 42d39a0

Browse files
chore: separate configuration (#1663)
1 parent 4c05ea7 commit 42d39a0

File tree

2 files changed

+117
-108
lines changed

2 files changed

+117
-108
lines changed

‎index.html‎

Lines changed: 1 addition & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -24,114 +24,7 @@
2424

2525
<body>
2626
<div id="app">LeetCode & Coding Interview Guide @Doocs</div>
27-
<script>
28-
const isEn = () => location.hash.includes('README_EN');
29-
const isRoot = () => ['', '#/', '#/README', '#/README_EN'].includes(location.hash);
30-
const sidebar = () => isRoot() ? false : (isEn() ? 'summary_en.md' : 'summary.md');
31-
const cleanedHtml = (html) => {
32-
return html.replace(/<pre>([\s\S]*?)<\/pre>/g, function (match, group) {
33-
return "<pre>" + group.replace(/<code>([\s\S]*?)<\/code>/g, "1ドル") + "</pre>";
34-
});
35-
};
36-
37-
window.addEventListener('hashchange', () => {
38-
window.$docsify.loadSidebar = sidebar();
39-
window.$docsify.pagination.previousText = isEn() ? 'PREVIOUS' : '上一题';
40-
window.$docsify.pagination.nextText = isEn() ? 'NEXT' : '下一题';
41-
});
42-
43-
window.$docsify = {
44-
name: 'leetcode',
45-
repo: 'doocs/leetcode',
46-
lastModifiedText: isEn() ? 'Last updated: ' : '最近更新时间:',
47-
logo: '/images/doocs-leetcode.png',
48-
search: {
49-
depth: 2,
50-
hideOtherSidebarContent: true,
51-
pathNamespaces: ['/', '/solution', '/lcof', '/lcof2', '/lcci', '/lcs', '/lcp', '/basic']
52-
},
53-
loadSidebar: sidebar(),
54-
auto2top: true,
55-
subMaxLevel: 2,
56-
alias: {
57-
'/lcs/.*/summary.md': '/lcs/summary.md',
58-
'/lcp/.*/summary.md': '/lcp/summary.md',
59-
'/lcci/.*/summary.md': '/lcci/summary.md',
60-
'/lcof/.*/summary.md': '/lcof/summary.md',
61-
'/lcof2/.*/summary.md': '/lcof2/summary.md',
62-
'/solution/.*/summary.md': '/solution/summary.md',
63-
'/basic/.*/summary.md': '/basic/summary.md',
64-
65-
'/lcs/.*/summary_en.md': '/lcs/summary_en.md',
66-
'/lcp/.*/summary_en.md': '/lcp/summary_en.md',
67-
'/lcci/.*/summary_en.md': '/lcci/summary_en.md',
68-
'/lcof/.*/summary_en.md': '/lcof/summary_en.md',
69-
'/lcof2/.*/summary_en.md': '/lcof2/summary_en.md',
70-
'/solution/.*/summary_en.md': '/solution/summary_en.md',
71-
'/basic/.*/summary_en.md': '/basic/summary_en.md',
72-
},
73-
contributors: {
74-
repo: 'doocs/leetcode',
75-
ignores: ['/README.md', '/README_EN.md', '/solution/README.md', '/solution/README_EN.md', '/summary.md'],
76-
image: {
77-
margin: '0.2em',
78-
isRound: true
79-
}
80-
},
81-
darklightTheme: {
82-
defaultTheme: 'light',
83-
siteFont: 'Source Sans Pro,Helvetica Neue,Arial,sans-serif',
84-
codeFontFamily: 'Roboto Mono, Monaco, courier, monospace',
85-
bodyFontSize: '15px',
86-
dark: {
87-
background: '#191919',
88-
highlightColor: '#e96900',
89-
codeBackgroundColor: '#202020',
90-
codeTextColor: '#b4b4b4',
91-
},
92-
light: {
93-
highlightColor: '#e96900',
94-
}
95-
},
96-
pagination: {
97-
previousText: isEn() ? 'PREVIOUS' : '上一题',
98-
nextText: isEn() ? 'NEXT' : '下一题',
99-
crossChapter: true,
100-
crossChapterText: true
101-
},
102-
tabs: {
103-
persist: true,
104-
sync: true,
105-
theme: 'classic',
106-
tabComments: true,
107-
tabHeadings: true
108-
},
109-
plugins: [
110-
(hook, vm) => {
111-
hook.beforeEach((html) => {
112-
const { file } = vm.route
113-
const userContent = /githubusercontent\.com/.test(file)
114-
const url = userContent ? file
115-
.replace('raw.githubusercontent.com', 'github.com')
116-
.replace(/\/main/, '/blob/main') : 'https://github.com/doocs/leetcode/blob/main/' + file
117-
118-
const github = `[GitHub](${url})`
119-
const gitee = `[Gitee](${url.replace("github", "gitee")})`
120-
html = cleanedHtml(html);
121-
const editHtml = isEn() ? `:memo: Edit on ${github} / ${gitee}\n` : `:memo: 在 ${github} / ${gitee} 编辑\n`
122-
return editHtml + html
123-
})
124-
125-
hook.afterEach((html) => {
126-
const copyright = isEn() ? '. All Rights Reserved' : ' 版权所有'
127-
const currentYear = new Date().getFullYear()
128-
const footer = `<footer>Copyright © 2018-${currentYear} <a href="https://github.com/doocs" target="_blank">Doocs</a>${copyright}</footer>`
129-
return html + footer
130-
})
131-
},
132-
]
133-
}
134-
</script>
27+
<script src="./main.js"></script>
13528
<script src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/docsify@4.13.0/lib/docsify.min.js"></script>
13629
<!-- components -->
13730
<script src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/prismjs/components/prism-c.min.js"></script>

‎main.js‎

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
const isEn = () => location.hash.includes('README_EN');
2+
const isRoot = () => ['', '#/', '#/README', '#/README_EN'].includes(location.hash);
3+
const sidebar = () => (isRoot() ? false : isEn() ? 'summary_en.md' : 'summary.md');
4+
const cleanedHtml = html => {
5+
return html.replace(/<pre>([\s\S]*?)<\/pre>/g, (_, group) => {
6+
return '<pre>' + group.replace(/<code>([\s\S]*?)<\/code>/g, '1ドル') + '</pre>';
7+
});
8+
};
9+
10+
window.addEventListener('hashchange', () => {
11+
window.$docsify.loadSidebar = sidebar();
12+
window.$docsify.pagination.previousText = isEn() ? 'PREVIOUS' : '上一题';
13+
window.$docsify.pagination.nextText = isEn() ? 'NEXT' : '下一题';
14+
});
15+
16+
window.$docsify = {
17+
name: 'leetcode',
18+
repo: 'doocs/leetcode',
19+
lastModifiedText: isEn() ? 'Last updated: ' : '最近更新时间:',
20+
logo: '/images/doocs-leetcode.png',
21+
search: {
22+
depth: 2,
23+
hideOtherSidebarContent: true,
24+
pathNamespaces: ['/', '/solution', '/lcof', '/lcof2', '/lcci', '/lcs', '/lcp', '/basic'],
25+
},
26+
loadSidebar: sidebar(),
27+
auto2top: true,
28+
subMaxLevel: 2,
29+
alias: {
30+
'/lcs/.*/summary.md': '/lcs/summary.md',
31+
'/lcp/.*/summary.md': '/lcp/summary.md',
32+
'/lcci/.*/summary.md': '/lcci/summary.md',
33+
'/lcof/.*/summary.md': '/lcof/summary.md',
34+
'/lcof2/.*/summary.md': '/lcof2/summary.md',
35+
'/solution/.*/summary.md': '/solution/summary.md',
36+
'/basic/.*/summary.md': '/basic/summary.md',
37+
38+
'/lcs/.*/summary_en.md': '/lcs/summary_en.md',
39+
'/lcp/.*/summary_en.md': '/lcp/summary_en.md',
40+
'/lcci/.*/summary_en.md': '/lcci/summary_en.md',
41+
'/lcof/.*/summary_en.md': '/lcof/summary_en.md',
42+
'/lcof2/.*/summary_en.md': '/lcof2/summary_en.md',
43+
'/solution/.*/summary_en.md': '/solution/summary_en.md',
44+
'/basic/.*/summary_en.md': '/basic/summary_en.md',
45+
},
46+
contributors: {
47+
repo: 'doocs/leetcode',
48+
ignores: [
49+
'/README.md',
50+
'/README_EN.md',
51+
'/solution/README.md',
52+
'/solution/README_EN.md',
53+
'/summary.md',
54+
],
55+
image: {
56+
margin: '0.2em',
57+
isRound: true,
58+
},
59+
},
60+
darklightTheme: {
61+
defaultTheme: 'light',
62+
siteFont: 'Source Sans Pro,Helvetica Neue,Arial,sans-serif',
63+
codeFontFamily: 'Roboto Mono, Monaco, courier, monospace',
64+
bodyFontSize: '15px',
65+
dark: {
66+
background: '#191919',
67+
highlightColor: '#e96900',
68+
codeBackgroundColor: '#202020',
69+
codeTextColor: '#b4b4b4',
70+
},
71+
light: {
72+
highlightColor: '#e96900',
73+
},
74+
},
75+
pagination: {
76+
previousText: isEn() ? 'PREVIOUS' : '上一题',
77+
nextText: isEn() ? 'NEXT' : '下一题',
78+
crossChapter: true,
79+
crossChapterText: true,
80+
},
81+
tabs: {
82+
persist: true,
83+
sync: true,
84+
theme: 'classic',
85+
tabComments: true,
86+
tabHeadings: true,
87+
},
88+
plugins: [
89+
(hook, vm) => {
90+
hook.beforeEach(html => {
91+
const { file } = vm.route;
92+
const isUserContent = /githubusercontent\.com/.test(file);
93+
const url = isUserContent
94+
? file
95+
.replace('raw.githubusercontent.com', 'github.com')
96+
.replace(/\/main/, '/blob/main')
97+
: `https://github.com/doocs/leetcode/blob/main/${file}`;
98+
99+
const github = `[GitHub](${url})`;
100+
const gitee = `[Gitee](${url.replace('github', 'gitee')})`;
101+
html = cleanedHtml(html);
102+
const editHtml = isEn()
103+
? `:memo: Edit on ${github} / ${gitee}\n`
104+
: `:memo: 在 ${github} / ${gitee} 编辑\n`;
105+
return editHtml + html;
106+
});
107+
108+
hook.afterEach(html => {
109+
const copyright = isEn() ? '. All Rights Reserved' : ' 版权所有';
110+
const currentYear = new Date().getFullYear();
111+
const footer = `<footer>Copyright © 2018-${currentYear} <a href="https://github.com/doocs" target="_blank">Doocs</a>${copyright}</footer>`;
112+
return html + footer;
113+
});
114+
},
115+
],
116+
};

0 commit comments

Comments
(0)

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