-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: separate configuration #1663
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
const isEn = () => location.hash.includes('README_EN'); | ||
const isRoot = () => ['', '#/', '#/README', '#/README_EN'].includes(location.hash); | ||
const sidebar = () => (isRoot() ? false : isEn() ? 'summary_en.md' : 'summary.md'); | ||
const cleanedHtml = html => { | ||
return html.replace(/<pre>([\s\S]*?)<\/pre>/g, (_, group) => { | ||
return '<pre>' + group.replace(/<code>([\s\S]*?)<\/code>/g, '$1') + '</pre>'; | ||
}); | ||
}; | ||
|
||
window.addEventListener('hashchange', () => { | ||
window.$docsify.loadSidebar = sidebar(); | ||
window.$docsify.pagination.previousText = isEn() ? 'PREVIOUS' : '上一题'; | ||
window.$docsify.pagination.nextText = isEn() ? 'NEXT' : '下一题'; | ||
}); | ||
|
||
window.$docsify = { | ||
name: 'leetcode', | ||
repo: 'doocs/leetcode', | ||
lastModifiedText: isEn() ? 'Last updated: ' : '最近更新时间:', | ||
logo: '/images/doocs-leetcode.png', | ||
search: { | ||
depth: 2, | ||
hideOtherSidebarContent: true, | ||
pathNamespaces: ['/', '/solution', '/lcof', '/lcof2', '/lcci', '/lcs', '/lcp', '/basic'], | ||
}, | ||
loadSidebar: sidebar(), | ||
auto2top: true, | ||
subMaxLevel: 2, | ||
alias: { | ||
'/lcs/.*/summary.md': '/lcs/summary.md', | ||
'/lcp/.*/summary.md': '/lcp/summary.md', | ||
'/lcci/.*/summary.md': '/lcci/summary.md', | ||
'/lcof/.*/summary.md': '/lcof/summary.md', | ||
'/lcof2/.*/summary.md': '/lcof2/summary.md', | ||
'/solution/.*/summary.md': '/solution/summary.md', | ||
'/basic/.*/summary.md': '/basic/summary.md', | ||
|
||
'/lcs/.*/summary_en.md': '/lcs/summary_en.md', | ||
'/lcp/.*/summary_en.md': '/lcp/summary_en.md', | ||
'/lcci/.*/summary_en.md': '/lcci/summary_en.md', | ||
'/lcof/.*/summary_en.md': '/lcof/summary_en.md', | ||
'/lcof2/.*/summary_en.md': '/lcof2/summary_en.md', | ||
'/solution/.*/summary_en.md': '/solution/summary_en.md', | ||
'/basic/.*/summary_en.md': '/basic/summary_en.md', | ||
}, | ||
contributors: { | ||
repo: 'doocs/leetcode', | ||
ignores: [ | ||
'/README.md', | ||
'/README_EN.md', | ||
'/solution/README.md', | ||
'/solution/README_EN.md', | ||
'/summary.md', | ||
], | ||
image: { | ||
margin: '0.2em', | ||
isRound: true, | ||
}, | ||
}, | ||
darklightTheme: { | ||
defaultTheme: 'light', | ||
siteFont: 'Source Sans Pro,Helvetica Neue,Arial,sans-serif', | ||
codeFontFamily: 'Roboto Mono, Monaco, courier, monospace', | ||
bodyFontSize: '15px', | ||
dark: { | ||
background: '#191919', | ||
highlightColor: '#e96900', | ||
codeBackgroundColor: '#202020', | ||
codeTextColor: '#b4b4b4', | ||
}, | ||
light: { | ||
highlightColor: '#e96900', | ||
}, | ||
}, | ||
pagination: { | ||
previousText: isEn() ? 'PREVIOUS' : '上一题', | ||
nextText: isEn() ? 'NEXT' : '下一题', | ||
crossChapter: true, | ||
crossChapterText: true, | ||
}, | ||
tabs: { | ||
persist: true, | ||
sync: true, | ||
theme: 'classic', | ||
tabComments: true, | ||
tabHeadings: true, | ||
}, | ||
plugins: [ | ||
(hook, vm) => { | ||
hook.beforeEach(html => { | ||
const { file } = vm.route; | ||
const isUserContent = /githubusercontent\.com/.test(file); | ||
const url = isUserContent | ||
? file | ||
.replace('raw.githubusercontent.com', 'github.com') | ||
.replace(/\/main/, '/blob/main') | ||
: `https://github.com/doocs/leetcode/blob/main/${file}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 换成模版字符串拼接 |
||
|
||
const github = `[GitHub](${url})`; | ||
const gitee = `[Gitee](${url.replace('github', 'gitee')})`; | ||
html = cleanedHtml(html); | ||
const editHtml = isEn() | ||
? `:memo: Edit on ${github} / ${gitee}\n` | ||
: `:memo: 在 ${github} / ${gitee} 编辑\n`; | ||
return editHtml + html; | ||
}); | ||
|
||
hook.afterEach(html => { | ||
const copyright = isEn() ? '. All Rights Reserved' : ' 版权所有'; | ||
const currentYear = new Date().getFullYear(); | ||
const footer = `<footer>Copyright © 2018-${currentYear} <a href="https://github.com/doocs" target="_blank">Doocs</a>${copyright}</footer>`; | ||
return html + footer; | ||
}); | ||
}, | ||
], | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
userContent
->isUserContent
, 一般bool 命名规范