Skip to content
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

feat: generate sub category summary #1699

Merged
merged 17 commits into from
Sep 26, 2023
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
- [剑指 Offer(专项突击版)](/lcof2/README.md)
- [程序员面试金典(第 6 版)](/lcci/README.md)

## 专项突破

- [JavaScript 专项练习](/solution/JAVASCRIPT_README.md)
- [数据库专项练习](/solution/DATABASE_README.md)

## 算法提升专题

### 1. 基础算法
Expand Down
5 changes: 5 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ The repository is maintained by the Doocs community, and please give us a [star]
- [LCOF: Coding Interviews, 2nd Edition](/lcof/README_EN.md)
- [LCCI: Cracking the Coding Interview, 6th Edition](/lcci/README_EN.md)

## JavaScript & Database Practice

- [JavaScript Practice](/solution/JAVASCRIPT_README_EN.md)
- [Database Practice](/solution/DATABASE_README_EN.md)

## Topics

### 1. Basic Algorithms
Expand Down
2 changes: 1 addition & 1 deletion lcci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

列表所有题解均由 [开源社区 Doocs](https://github.com/doocs) 贡献者提供,正在完善中,欢迎贡献你的题解!

快速搜索题号、题解、标签等,请善用 <kbd>Control</kbd>+<kbd>F</kbd>(或者 <kbd>Command</kbd>+<kbd>F</kbd>)。
快速搜索题号、题解、标签等,请善用 <kbd>Control</kbd> + <kbd>F</kbd>(或者 <kbd>Command</kbd> + <kbd>F</kbd>)。

| 题号 | 题解 | 标签 | 难度 |
| --------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | --------------------------------------------- | ---- |
Expand Down
2 changes: 1 addition & 1 deletion lcci/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ _Cracking the Coding Interview, 6th Edition_ is here to help you through this pr

## Solutions

Press <kbd>Control</kbd>+<kbd>F</kbd>(or <kbd>Command</kbd>+<kbd>F</kbd> on the Mac) to search anything you want.
Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on the Mac) to search anything you want.

| # | Solution | Tag | Difficulty |
| --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | ---------- |
Expand Down
2 changes: 1 addition & 1 deletion lcof/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

列表所有题解均由 [开源社区 Doocs](https://github.com/doocs) 贡献者提供,正在完善中,欢迎贡献你的题解!

快速搜索题号、题解、标签等,请善用 <kbd>Control</kbd>+<kbd>F</kbd>(或者 <kbd>Command</kbd>+<kbd>F</kbd>)。
快速搜索题号、题解、标签等,请善用 <kbd>Control</kbd> + <kbd>F</kbd>(或者 <kbd>Command</kbd> + <kbd>F</kbd>)。

| 题号 | 题解 | 标签 | 难度 |
| ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ---- |
Expand Down
2 changes: 1 addition & 1 deletion lcof/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Readers will improve their interview performance after reading this book. It wil

English Solutions is not available for the book. Please switch to Chinese version.

Press <kbd>Control</kbd>+<kbd>F</kbd>(or <kbd>Command</kbd>+<kbd>F</kbd> on the Mac) to search anything you want.
Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on the Mac) to search anything you want.

## Copyright

Expand Down
2 changes: 1 addition & 1 deletion lcof2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

列表所有题解均由 [开源社区 Doocs](https://github.com/doocs) 贡献者提供,正在完善中,欢迎贡献你的题解!

快速搜索题号、题解、标签等,请善用 <kbd>Control</kbd>+<kbd>F</kbd>(或者 <kbd>Command</kbd>+<kbd>F</kbd>)。
快速搜索题号、题解、标签等,请善用 <kbd>Control</kbd> + <kbd>F</kbd>(或者 <kbd>Command</kbd> + <kbd>F</kbd>)。

| 题号 | 题解 | 标签 | 难度 | 备注 |
| ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ---- | ---- |
Expand Down
2 changes: 1 addition & 1 deletion lcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

列表所有题解均由 [开源社区 Doocs](https://github.com/doocs) 贡献者提供,正在完善中,欢迎贡献你的题解!

快速搜索题号、题解、标签等,请善用 <kbd>Control</kbd>+<kbd>F</kbd>(或者 <kbd>Command</kbd>+<kbd>F</kbd>)。
快速搜索题号、题解、标签等,请善用 <kbd>Control</kbd> + <kbd>F</kbd>(或者 <kbd>Command</kbd> + <kbd>F</kbd>)。

| 题号 | 题解 | 标签 | 难度 |
| -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- | ---- |
Expand Down
2 changes: 1 addition & 1 deletion lcs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

列表所有题解均由 [开源社区 Doocs](https://github.com/doocs) 贡献者提供,正在完善中,欢迎贡献你的题解!

快速搜索题号、题解、标签等,请善用 <kbd>Control</kbd>+<kbd>F</kbd>(或者 <kbd>Command</kbd>+<kbd>F</kbd>)。
快速搜索题号、题解、标签等,请善用 <kbd>Control</kbd> + <kbd>F</kbd>(或者 <kbd>Command</kbd> + <kbd>F</kbd>)。

| 题号 | 题解 | 标签 | 难度 | 备注 |
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | ---- | ---- |
Expand Down
40 changes: 38 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,52 @@ 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 categories = ['javascript', 'database'];

const getSolutionPrefix = url => {
const res = categories.find(
category =>
url.includes(category + '-solution') ||
url.includes(category.toUpperCase() + '_README'),
);
return res ? res + '-' : '';
};

const sidebar = () => {
if (isRoot()) {
return false;
}
const prefix = getSolutionPrefix(location.hash);
return isEn() ? `${prefix}summary_en.md` : `${prefix}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>';
});
};

const replaceHref = html => {
const prefix = getSolutionPrefix(location.hash);
return prefix ? html.replaceAll('(/solution/', '(/' + prefix + 'solution/') : html;
};

const getLang = () => (isEn() ? 'en' : 'zh-CN');

const giscusTheme = () =>
localStorage.getItem('DARK_LIGHT_THEME') === 'light' ? 'light' : 'noborder_dark';

const getTerm = () => decodeURI(location.hash.slice(1, location.hash.lastIndexOf('/')) || '/index');
const getTerm = () => {
let path = decodeURI(location.hash.slice(1, location.hash.lastIndexOf('/'))) || '/index';
// restore original path
for (const prefix of categories) {
const s = `${prefix}-solution`;
if (path.includes(s)) {
path = path.replace(s, 'solution');
}
}
return path;
};

window.addEventListener('hashchange', () => {
window.$docsify.loadSidebar = sidebar();
Expand All @@ -34,6 +66,9 @@ window.$docsify = {
auto2top: true,
subMaxLevel: 2,
alias: {
'^/javascript-solution/(.*)': '/solution/$1',
'^/shell-solution/(.*)': '/solution/$1',
'^/database-solution/(.*)': '/solution/$1',
'/lcs/.*/summary.md': '/lcs/summary.md',
'/lcp/.*/summary.md': '/lcp/summary.md',
'/lcci/.*/summary.md': '/lcci/summary.md',
Expand Down Expand Up @@ -128,6 +163,7 @@ window.$docsify = {
const github = `[GitHub](${url})`;
const gitee = `[Gitee](${url.replace('github', 'gitee')})`;
html = cleanedHtml(html);
html = replaceHref(html);
const editHtml = isEn()
? `:memo: Edit on ${github} / ${gitee}\n`
: `:memo: 在 ${github} / ${gitee} 编辑\n`;
Expand Down
Loading