mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-17 12:41:20 +08:00
Compare commits
31 Commits
Author | SHA1 | Date | |
---|---|---|---|
37c9f23952 | |||
cb704eed88 | |||
75fece7aab | |||
3966175a39 | |||
0c03059cde | |||
efae1dc846 | |||
4132a13a96 | |||
bd082908d8 | |||
dd8a3cb26d | |||
6d0801a9da | |||
6290b9eae0 | |||
9479626194 | |||
ad4b2e9119 | |||
d48341cecb | |||
5aec989c14 | |||
13492fe556 | |||
d145aaa0b0 | |||
531c01d62e | |||
0a160d22d8 | |||
0a070e996c | |||
54faf5c19c | |||
09f57d1848 | |||
f875a335e1 | |||
b743110c9d | |||
d1c9871504 | |||
a478fbb888 | |||
fdcfcb287b | |||
3003e3db66 | |||
ca1f5ad470 | |||
d0d371b165 | |||
54b7faee00 |
15
.github/ISSUE_TEMPLATE/cheatsheet-request.md
vendored
15
.github/ISSUE_TEMPLATE/cheatsheet-request.md
vendored
@ -5,21 +5,16 @@ title: '备忘清单 请求: '
|
||||
labels: request
|
||||
assignees: jaywcjlove
|
||||
---
|
||||
备忘清单标题 备忘清单
|
||||
【备忘清单标题】 备忘清单
|
||||
===
|
||||
|
||||
这是您可以在 Quick Reference 备忘清单上使用的参考!【备忘清单介绍】
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### 卡片 1
|
||||
如果有一张备忘单(速查表) [`参考这里`](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md) 为仓库贡献。
|
||||
|
||||
### 卡片 2
|
||||
|
||||
### 卡片 3
|
||||
|
||||
另见
|
||||
提供参考资料地址
|
||||
----
|
||||
|
||||
- [参考地址](https://xxx.com)
|
||||
- [参考地址 1](https://xxx.com)
|
||||
- [官网地址](https://xxx.com)
|
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
@ -16,6 +16,13 @@ jobs:
|
||||
- run: npm install
|
||||
- run: npm run build
|
||||
|
||||
- name: Generate Contributors Images
|
||||
uses: jaywcjlove/github-action-contributors@main
|
||||
with:
|
||||
filter-author: (renovate\[bot\]|renovate-bot|dependabot\[bot\])
|
||||
output: dist/CONTRIBUTORS.svg
|
||||
avatarSize: 42
|
||||
|
||||
- name: Create Tag
|
||||
id: create_tag
|
||||
uses: jaywcjlove/create-tag-action@main
|
||||
|
4
.husky/pre-commit
Executable file
4
.husky/pre-commit
Executable file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
npx --no-install lint-staged
|
3
.lintstagedrc
Normal file
3
.lintstagedrc
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"**/*.{mjs,css,json,prettierrc,lintstagedrc}": ["prettier --write"]
|
||||
}
|
5
.prettierignore
Normal file
5
.prettierignore
Normal file
@ -0,0 +1,5 @@
|
||||
package.json
|
||||
coverage
|
||||
dist
|
||||
build
|
||||
docs
|
9
.prettierrc
Normal file
9
.prettierrc
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all",
|
||||
"printWidth": 120,
|
||||
"overrides": [
|
||||
{ "files": ".prettierrc", "options": { "parser": "json" } },
|
||||
{ "files": ".lintstagedrc", "options": { "parser": "json" } }
|
||||
]
|
||||
}
|
@ -16,6 +16,26 @@ Contributing 贡献
|
||||
|
||||
只需要 `标题<h1>` 和`介绍`(标题下面)。脚本会自动识别,通过 GitHub Actions 自动发布 [`Quick Reference`](https://jaywcjlove.github.io/reference) 网站。
|
||||
|
||||
## 目录结构
|
||||
|
||||
```bash
|
||||
.
|
||||
├── CONTRIBUTING.md # 贡献说明
|
||||
├── Dockerfile
|
||||
├── LICENSE
|
||||
├── README.md # Home(首页) 内容
|
||||
├── dist # 编译后的静态资源目录
|
||||
├── docs # Markdown 文档(快速参考备忘清单【速查表】)
|
||||
│ ├── bash.md
|
||||
│ ├── ....
|
||||
│ └── yaml.md
|
||||
├── package.json
|
||||
└── scripts # MD 转 HTML 的编译脚本
|
||||
├── assets # 存放首页 svg 图标文件资源,与 `dosc` 文件名对应
|
||||
├── ....
|
||||
└── watch.mjs
|
||||
```
|
||||
|
||||
## CSS 类注释
|
||||
|
||||
[`Quick Reference`](https://jaywcjlove.github.io/reference) 使用 [`@wcj/markdown-to-html`](https://github.com/jaywcjlove/markdown-to-html) 转换 `Markdown`,并使用 [`rehype-attr`](https://github.com/jaywcjlove/rehype-attr) 插件让其支持通过其注释语法添加类和样式。 此外,您可以在 Quick Reference 备忘清单上使用样式参考:https://jaywcjlove.github.io/reference/docs/quickreference.html
|
||||
@ -34,6 +54,13 @@ Contributing 贡献
|
||||
<!--rehype:class=home-card-->
|
||||
```
|
||||
|
||||
首页导航图标存放在 `scripts/assets` 目录中,如果你的备忘清单定义为 `docs/cron.md`,那么你的图标就定义为 `cron.svg` 存放到 `scripts/assets` 目录中,重新编译首页当行菜单就拥有了图标。
|
||||
|
||||
- 图标存放在 [`scripts/assets`](https://github.com/jaywcjlove/reference/blob/main/scripts/assets) 目录中
|
||||
- 图片名称与清单名称保持一致 `cron.md` -> `cron.svg` (注意大小写)
|
||||
- SVG 图标尺寸 `<svg height="1em" width="1em"`
|
||||
- SVG 图标颜色使用继承颜色值 `<svg fill="currentColor"`
|
||||
|
||||
## 本地开发
|
||||
|
||||
```bash
|
||||
|
22
README.md
22
README.md
@ -9,10 +9,10 @@ Quick Reference
|
||||
<!--rehype:ignore:end-->
|
||||
|
||||
<!--rehype:ignore:start-->
|
||||
[](https://jaywcjlove.github.io/reference)
|
||||
[](https://jaywcjlove.github.io/reference)
|
||||
<!--rehype:ignore:end-->
|
||||
|
||||
为开发人员分享快速参考备忘清单(主要是方便自己),在看到 [Reference](https://github.com/Randy8080/reference) 快速参考备忘单,感觉非常简单,造轮子使命感突然来了,造个中文版本的,为了方便自己的技术栈查阅,立马撸起来 :)。如果您发现此处的备忘单不合适,您可以通过提交 [PR](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md) 来修复它或提供更好的备忘清单,只针对【中文】用户。以下是开源天使提供的一些备忘清单和快速参考 :)。
|
||||
为开发人员分享快速参考备忘清单【速查表】 _(主要是方便自己)_,在看到 [Reference](https://github.com/Randy8080/reference) 快速参考备忘单,感觉非常简单,造轮子使命感突然来了,造个中文版本的,为了方便自己的技术栈查阅,立马撸起来 :)。如果您发现此处的备忘单不合适,您可以通过提交 [PR](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md) 来修复它或提供更好的备忘清单,只针对【中文】用户。以下是开源天使提供的一些备忘清单和快速参考 :)。
|
||||
|
||||
## 编程
|
||||
|
||||
@ -21,9 +21,12 @@ Quick Reference
|
||||
[Docker](./docs/docker.md)<!--rehype:style=background: rgb(72 143 223/var(\-\-bg\-opacity));-->
|
||||
[Dockerfile](./docs/dockerfile.md)<!--rehype:style=background: rgb(0 72 153/var(\-\-bg\-opacity));-->
|
||||
[Golang](./docs/golang.md)<!--rehype:style=background: rgb(39 160 193/var(\-\-bg\-opacity));-->
|
||||
[INI](./docs/ini.md)<!--rehype:style=background: rgb(57 59 60/var(\-\-bg\-opacity));-->
|
||||
[JSON](./docs/json.md)<!--rehype:style=background: rgb(57 59 60/var(\-\-bg\-opacity));-->
|
||||
[Markdown](./docs/markdown.md)<!--rehype:style=background: rgb(103 61 156/var(\-\-bg\-opacity));-->
|
||||
[MySQL](./docs/mysql.md)<!--rehype:style=background: rgb(103 61 156/var(\-\-bg\-opacity));-->
|
||||
[Swift](./docs/swift.md)<!--rehype:style=background: rgb(240 81 57/var(\-\-bg\-opacity));-->
|
||||
[SwiftUI](./docs/swiftui.md)<!--rehype:style=background: rgb(10 127 247/var(\-\-bg\-opacity));-->
|
||||
[TOML](./docs/toml.md)<!--rehype:style=background: rgb(132 132 132/var(\-\-bg\-opacity));-->
|
||||
[YAML](./docs/yaml.md)<!--rehype:style=background: rgb(91 163 230/var(\-\-bg\-opacity));-->
|
||||
<!--rehype:class=home-card-->
|
||||
@ -47,6 +50,7 @@ Quick Reference
|
||||
[RegEx](./docs/regex.md)<!--rehype:style=background: rgb(149 36 155/var(\-\-bg\-opacity));-->
|
||||
[TypeScript](./docs/typescript.md)<!--rehype:style=background: rgb(49 120 198/var(\-\-bg\-opacity));-->
|
||||
[Vue 2](./docs/vue2.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));-->
|
||||
[Vue 3 (努力中...)](./docs/vue.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
## Nodejs
|
||||
@ -100,11 +104,21 @@ Quick Reference
|
||||
|
||||
上面的列表没有看到你想要的? 您是否正在寻找一些备忘清单或参考资料,或者您有一些片段备忘清单要分享,这是一个最好的机会!
|
||||
|
||||
[`请求添加备忘单`](https://github.com/jaywcjlove/reference/issues/new?title=【备忘清单】+请求%3A+&labels=request&template=cheatsheet-request.md&assignee=jaywcjlove)<!--rehype:class=home-button&style=margin-top:2rem&target=__blank-->
|
||||
[`我有一张备忘单`](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md)<!--rehype:class=home-button text-grey&target=__blank-->
|
||||
[`请求添加备忘单(速查表)`](https://github.com/jaywcjlove/reference/issues/new?title=【备忘清单】+请求%3A+&labels=request&template=cheatsheet-request.md&assignee=jaywcjlove)<!--rehype:class=home-button&style=margin-top:2rem&target=__blank-->
|
||||
[`我有一张备忘单(速查表)`](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md)<!--rehype:class=home-button text-grey&target=__blank-->
|
||||
<!--rehype:style=margin-top:3rem-->
|
||||
|
||||
<!--rehype:ignore:start-->
|
||||
## 贡献
|
||||
|
||||
请参阅[贡献指南](./CONTRIBUTING.md)了解如何开始。一如既往,感谢我们出色的贡献者!
|
||||
|
||||
<a href="https://github.com/jaywcjlove/reference/graphs/contributors">
|
||||
<img src="https://jaywcjlove.github.io/reference/CONTRIBUTORS.svg" />
|
||||
</a>
|
||||
|
||||
上图贡献者列表,由 [contributors](https://github.com/jaywcjlove/github-action-contributors) 自动生成贡献者图片。
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Kenny Wong](https://github.com/jaywcjlove)
|
||||
|
@ -34,11 +34,9 @@ NAME = "John" # => Error (关于空间)
|
||||
|
||||
### 注释
|
||||
|
||||
```bash
|
||||
# 这是一个内联 Bash 注释。
|
||||
```
|
||||
|
||||
```shell
|
||||
# 这是一个内联 Bash 注释。
|
||||
|
||||
: '
|
||||
这是一个
|
||||
非常整洁的评论
|
||||
|
244
docs/chmod.md
244
docs/chmod.md
@ -31,10 +31,21 @@ $ chmod -R 755 my_directory
|
||||
|
||||
### Chmod 生成器
|
||||
|
||||
```html
|
||||
|
||||
```html preview
|
||||
<div>
|
||||
权限:<input type="text" id="num" placeholder="777" maxlength="3" style="padding: 0.3rem 0.3rem;" /> <input type="text" id="let" placeholder="rwxrwxrwx" maxlength="9" style="padding: 0.3rem 0.3rem;" />
|
||||
</div>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
| User | Group | Other
|
||||
:- | :- | :- | :-
|
||||
读 _(Read)_ | <input checked id="1" type="checkbox"></input> | <input checked id="4" type="checkbox"></input> | <input checked id="7" type="checkbox"></input>
|
||||
写 _(Write)_ | <input checked id="2" type="checkbox"></input> | <input checked id="5" type="checkbox"></input> | <input checked id="8" type="checkbox"></input>
|
||||
执行 _(Execute)_ | <input checked id="3" type="checkbox"></input> | <input checked id="6" type="checkbox"></input> | <input checked id="9" type="checkbox"></input>
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
Chmod 生成器允许您以数字和符号的形式快速、直观地生成权限。
|
||||
|
||||
### 通用权限
|
||||
@ -264,3 +275,232 @@ $ find /path -type f -exec chmod 644 {} \;
|
||||
----
|
||||
|
||||
* [使用 chmod 修改文件权限](https://www.linode.com/docs/guides/modify-file-permissions-with-chmod/) _(linode.com)_
|
||||
|
||||
<!--rehype:ignore:start-->
|
||||
### 以下是 Chmod 生成器 JS 代码(代码用于网站请忽略不要删除)
|
||||
<!--rehype:ignore:end-->
|
||||
|
||||
```html preview
|
||||
<!-- Chmod 生成器 JS 代码 -->
|
||||
<script type="text/javascript">
|
||||
const reg_num = /^[0-7]{3}$/; // 一些正则表达式来检查 num 输入
|
||||
const reg_let = /^([r\-]{1}[w\-]{1}[x\-]{1}){3}$/; // 一些正则表达式来检查文本输入
|
||||
function checkBoxHandle() {
|
||||
change_occured(true, false, false);
|
||||
// get rid of bad input classes
|
||||
document.getElementById('num').classList.remove('bad-input');
|
||||
document.getElementById('let').classList.remove('bad-input');
|
||||
}
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
// loop over all the check boxes
|
||||
for (let i = 1; i < 10; i++) {
|
||||
let checkBox = document.getElementById(`${i}`);
|
||||
checkBox.addEventListener('change', function () {
|
||||
change_occured(true, false, false);
|
||||
|
||||
// get rid of bad input classes
|
||||
document.getElementById('num').classList.remove('bad-input');
|
||||
|
||||
document.getElementById('let').classList.remove('bad-input');
|
||||
});
|
||||
}
|
||||
// the octal input
|
||||
let num_input = document.getElementById('num');
|
||||
let num_fn = function () {
|
||||
// check for bad input
|
||||
if (!reg_num.test(this.value)) {
|
||||
this.classList.add('bad-input');
|
||||
} else {
|
||||
this.classList.remove('bad-input');
|
||||
change_occured(false, true, false);
|
||||
}
|
||||
};
|
||||
num_input.addEventListener('change', num_fn);
|
||||
num_input.addEventListener('keyup', num_fn);
|
||||
// the let input
|
||||
let let_input = document.getElementById('let');
|
||||
let let_fn = function () {
|
||||
// check for bad input
|
||||
if (!reg_let.test(this.value)) {
|
||||
this.classList.add('bad-input');
|
||||
} else {
|
||||
this.classList.remove('bad-input');
|
||||
change_occured(false, false, true);
|
||||
}
|
||||
};
|
||||
let_input.addEventListener('change',let_fn);
|
||||
let_input.addEventListener('keyup',let_fn);
|
||||
});
|
||||
/* SETUP
|
||||
r-4-1 r-4-4 r-4-7
|
||||
w-2-2 w-2-5 w-2-8
|
||||
x-1-3 x-1-6 x-1-9
|
||||
*/
|
||||
// define a function that runs when a change occures
|
||||
function change_occured(caller_was_check, caller_was_num, caller_was_let) {
|
||||
let num1 = 0, num2 = 0, num3 = 0; // these are the three numbers for the octal
|
||||
let perm_string = ''; // holds the permision string ex. rw-x--r--
|
||||
if (caller_was_check) {
|
||||
// loop over all the check boxes and get the permisions
|
||||
for (let i = 1; i < 10; i++) {
|
||||
let checkBox = document.getElementById(`${i}`);
|
||||
if (checkBox.checked) { // if checked
|
||||
let current_perm = check_to_octal_and_text(i);
|
||||
perm_string += `${current_perm.perm_let}`;
|
||||
if (i <= 3) {
|
||||
num1 += current_perm.perm_num;
|
||||
} else if (i <= 6) {
|
||||
num2 += current_perm.perm_num;
|
||||
} else {
|
||||
num3 += current_perm.perm_num;
|
||||
}
|
||||
} else { // if not checked
|
||||
perm_string += '-';
|
||||
}
|
||||
}
|
||||
// set the permision input text
|
||||
document.getElementById('let').value = perm_string;
|
||||
document.getElementById('num').value = `${num1}${num2}${num3}`;
|
||||
} else if (caller_was_num) {
|
||||
// get the individual numbers
|
||||
let num_input_val = document.getElementById('num').value;
|
||||
num1 = num_input_val.substring(0, 1);
|
||||
num2 = num_input_val.substring(1, 2);
|
||||
num3 = num_input_val.substring(2, 3);
|
||||
// set the checkboxes and get the perm string
|
||||
perm_string += octal_to_check_and_txt(num1, 0); //Owner
|
||||
perm_string += octal_to_check_and_txt(num2, 1); //Owner
|
||||
perm_string += octal_to_check_and_txt(num3, 2); //Owner
|
||||
// set the permision input text
|
||||
document.getElementById('let').value = perm_string;
|
||||
} else if (caller_was_let) {
|
||||
// get the text input
|
||||
let perm_text = document.getElementById('let').value;
|
||||
num1 = text_to_check_and_octal(perm_text.substring(0, 3), 0)
|
||||
num2 = text_to_check_and_octal(perm_text.substring(3, 6), 3)
|
||||
num3 = text_to_check_and_octal(perm_text.substring(6, 9), 6)
|
||||
// set the octal value
|
||||
document.getElementById('num').value = `${num1}${num2}${num3}`;
|
||||
}
|
||||
}
|
||||
// define a function to converts the checkbox # to the respective permissions
|
||||
// returns perm_num, perm_let
|
||||
function check_to_octal_and_text(check_num) {
|
||||
let perm_num = 0;
|
||||
let perm_let = '-';
|
||||
switch (check_num) {
|
||||
case 1:
|
||||
case 4:
|
||||
case 7:
|
||||
perm_num = 4;
|
||||
perm_let = 'r';
|
||||
break;
|
||||
case 2:
|
||||
case 5:
|
||||
case 8:
|
||||
perm_num = 2;
|
||||
perm_let = 'w';
|
||||
break;
|
||||
case 3:
|
||||
case 6:
|
||||
case 9:
|
||||
perm_num = 1;
|
||||
perm_let = 'x';
|
||||
break;
|
||||
default:
|
||||
perm_num = 0;
|
||||
perm_let = '-';
|
||||
}
|
||||
// return values
|
||||
return {
|
||||
perm_num,
|
||||
perm_let
|
||||
};
|
||||
}
|
||||
/**
|
||||
Takes a number 1-7 and which class it is in:
|
||||
0 = owner
|
||||
1 = Group
|
||||
2 = Public
|
||||
Returns: perm text (ex. "rwx") and sets the appropriate checkboxes
|
||||
*/
|
||||
function octal_to_check_and_txt(octal_num, class_num) {
|
||||
let perm_text = '';
|
||||
let offset = class_num * 3;
|
||||
switch (octal_num) {
|
||||
case '1':
|
||||
document.getElementById(`${1 + offset}`).checked = false;
|
||||
document.getElementById(`${2 + offset}`).checked = false;
|
||||
document.getElementById(`${3 + offset}`).checked = true;
|
||||
perm_text = '--x';
|
||||
break;
|
||||
case '2':
|
||||
document.getElementById(`${1 + offset}`).checked = false;
|
||||
document.getElementById(`${2 + offset}`).checked = true;
|
||||
document.getElementById(`${3 + offset}`).checked = false;
|
||||
perm_text = '-w-';
|
||||
break;
|
||||
case '3':
|
||||
document.getElementById(`${1 + offset}`).checked = false;
|
||||
document.getElementById(`${2 + offset}`).checked = true;
|
||||
document.getElementById(`${3 + offset}`).checked = true;
|
||||
perm_text = '-wx';
|
||||
break;
|
||||
case '4':
|
||||
document.getElementById(`${1 + offset}`).checked = true;
|
||||
document.getElementById(`${2 + offset}`).checked = false;
|
||||
document.getElementById(`${3 + offset}`).checked = false;
|
||||
perm_text = 'r--';
|
||||
break;
|
||||
case '5':
|
||||
document.getElementById(`${1 + offset}`).checked = true;
|
||||
document.getElementById(`${2 + offset}`).checked = false;
|
||||
document.getElementById(`${3 + offset}`).checked = true;
|
||||
perm_text = 'r-x';
|
||||
break;
|
||||
case '6':
|
||||
document.getElementById(`${1 + offset}`).checked = true;
|
||||
document.getElementById(`${2 + offset}`).checked = true;
|
||||
document.getElementById(`${3 + offset}`).checked = false;
|
||||
perm_text = 'rw-';
|
||||
break;
|
||||
case '7':
|
||||
document.getElementById(`${1 + offset}`).checked = true;
|
||||
document.getElementById(`${2 + offset}`).checked = true;
|
||||
document.getElementById(`${3 + offset}`).checked = true;
|
||||
perm_text = 'rwx';
|
||||
break;
|
||||
default:
|
||||
document.getElementById(`${1 + offset}`).checked = false;
|
||||
document.getElementById(`${2 + offset}`).checked = false;
|
||||
document.getElementById(`${3 + offset}`).checked = false;
|
||||
perm_text = '---';
|
||||
}
|
||||
return perm_text;
|
||||
}
|
||||
/**
|
||||
Takes 3 letters (r, w, x, - ex. 'rw-') and an offset (0,3,6)
|
||||
Returns the octal num and sets the appropriate checkboxes
|
||||
*/
|
||||
function text_to_check_and_octal(letters, offset) {
|
||||
let perm_num = 0; // the octal number to return
|
||||
// add up the oct num and set the check boxes
|
||||
for (let i = 0; i < 3; i++) {
|
||||
current_let = letters.substring(i, i + 1);
|
||||
if (current_let == 'r') {
|
||||
document.getElementById(`${i + 1 + offset}`).checked = true;
|
||||
perm_num += 4;
|
||||
} else if (current_let == 'w') {
|
||||
document.getElementById(`${i + 1 + offset}`).checked = true;
|
||||
perm_num += 2;
|
||||
} else if (current_let == 'x') {
|
||||
document.getElementById(`${i + 1 + offset}`).checked = true;
|
||||
perm_num += 1;
|
||||
} else {
|
||||
document.getElementById(`${i + 1 + offset}`).checked = false;
|
||||
}
|
||||
}
|
||||
return perm_num;
|
||||
}
|
||||
</script>
|
||||
```
|
@ -95,7 +95,7 @@ Min Hour Day Mon Weekday
|
||||
`L` | 仅允许用于 `月份中的某天` 或 `星期几` 字段,`星期几` 中的 `2L` 表示每个月的最后一个星期二
|
||||
`井号 (#)` | 仅允许用于 `星期几` 字段,后面必须在 1 到 5 的范围内。例如,`4#1` 表示给定月份的“第一个星期四”。
|
||||
`问号(?)` | 可以代替“*”并允许用于月份和星期几。使用仅限于 cron 表达式中的 `月份中的某天` 或 `星期几`。
|
||||
<!--rehype:className=show-header -->
|
||||
<!--rehype:className=show-header auto-wrap-->
|
||||
|
||||
|
||||
## Also see
|
||||
|
@ -110,7 +110,7 @@ apk add --update curl # alpine linux 中安装
|
||||
`curl --connect-timeout 10 -I -k https://www.baidu.com` | `curl` 默认没有超时
|
||||
`curl --verbose --header "Host: www.mytest.com:8182" www.baidu.com` | `curl` 得到额外的标题
|
||||
`curl -k -v https://www.google.com` | `curl` 获取带有标题的响应
|
||||
|
||||
<!--rehype:class=auto-wrap-->
|
||||
|
||||
### 多文件上传
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
@ -136,6 +136,7 @@ $ curl -XGET http://${elasticsearch_ip}:9200/_cluster/nodes | python -m json.too
|
||||
:- | :-
|
||||
`curl -d "name=username&password=123456" <URL>` | `curl` 发请求
|
||||
`curl <URL> -H "content-type: application/json" -d "{ \"woof\": \"bark\"}"` | `curl` 发送 json
|
||||
<!--rehype:class=auto-wrap-->
|
||||
|
||||
### CURL 脚本安装 rvm
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
@ -156,6 +157,7 @@ curl -sSL https://get.rvm.io | bash
|
||||
`curl -T cryptopp552.zip -u test:test ftp://10.32.99.187/` | curl `ftp` 上传
|
||||
`curl -u test:test ftp://10.32.99.187/cryptopp552.zip -o cryptopp552.zip` | curl `ftp` 下载
|
||||
`curl -v -u admin:admin123 --upload-file package1.zip http://mysever:8081/dir/package1.zip` | 使用凭证 `curl` 上传
|
||||
<!--rehype:class=auto-wrap-->
|
||||
|
||||
### 检查网站响应时间
|
||||
<!--rehype:wrap-class=col-span-4-->
|
||||
|
@ -110,6 +110,7 @@ RUN true | false # 将脱离管道
|
||||
`CMD ["executable","param1","param2"]` | (exec 形式,这是首选形式)
|
||||
`CMD ["param1","param2"]` | (作为 ENTRYPOINT 的默认参数)
|
||||
`CMD command param1 param2` | (shell形式)
|
||||
<!--rehype:class=auto-wrap-->
|
||||
|
||||
```dockerfile
|
||||
EXPOSE 5900
|
||||
@ -185,6 +186,7 @@ temp?
|
||||
`*/temp*` | 在根的任何直接子目录中<br />排除名称以 `temp` 开头的文件和目录
|
||||
`*/*/temp*` | 从根以下两级的任何子目录中<br />排除以 `temp` 开头的文件和目录
|
||||
`temp?` | 排除根目录中名称为<br /> `temp` 的单字符扩展名的文件和目录
|
||||
<!--rehype:class=auto-wrap-->
|
||||
|
||||
如果此文件存在,排除与其中的模式匹配的文件和目录,有利于避免 `ADD` 或 `COPY` 将敏感文件添加到镜像中。匹配是使用 Go 的 [filepath.Match](https://golang.org/pkg/path/filepath#Match) 规则完成的。
|
||||
|
||||
@ -203,6 +205,7 @@ temp?
|
||||
`CMD command param1 param2` | 设置默认命令
|
||||
`ENV <key>=<value> ...` | 设置环境变量
|
||||
`EXPOSE <port> [<port>/<protocol>...]` | 运行时侦听指定的网络端口
|
||||
<!--rehype:class=auto-wrap-->
|
||||
|
||||
### 服务静态网站的最小 Docker 镜像
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
@ -340,7 +340,7 @@ env:
|
||||
myHexNumber: ${{ 0xff }}
|
||||
myExponentialNumber: ${{ -2.99e-2 }}
|
||||
myString: Mona the Octocat
|
||||
myStringInBraces: ${{ 'It''s open source!' }}
|
||||
myStringInBraces: ${{ 'It''s source!' }}
|
||||
```
|
||||
|
||||
### 函数 contains
|
||||
@ -375,6 +375,7 @@ startsWith('Hello world', 'He') // 返回 true
|
||||
format('{{Hello {0} {1} {2}!}}', 'Mona', 'the', 'Octocat')
|
||||
// 返回 '{Hello Mona the Octocat!}'.
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
另见: [函数 format](https://docs.github.com/cn/actions/learn-github-actions/expressions#format)
|
||||
|
||||
@ -815,6 +816,24 @@ steps:
|
||||
|
||||
您可以使用 `shell` 关键字覆盖运行器操作系统中的默认 `shell` 设置
|
||||
|
||||
### 一些 actions 推荐
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
[`create-tag-action`](https://github.com/jaywcjlove/create-tag-action) | 根据 package.json 创建 `Tag` / `Release`
|
||||
[`changelog-generator`](https://github.com/jaywcjlove/changelog-generator) | 生成 `changelog` 日志
|
||||
[`github-action-modify-file-content`](https://github.com/jaywcjlove/github-action-modify-file-content) | 修改仓库文件内容
|
||||
[`github-action-contributors`](https://github.com/jaywcjlove/github-action-contributors) | 生成贡献(contributors.svg)图片
|
||||
[`generated-badges`](https://github.com/jaywcjlove/generated-badges) | 生成徽章(Badges)图片
|
||||
[`coverage-badges-cli`](https://github.com/jaywcjlove/coverage-badges-cli) | 生成覆盖率徽章(Badges)图片
|
||||
[`action-ejs`](https://github.com/jaywcjlove/action-ejs) | 基于 ejs 生成 HTML
|
||||
[`github-action-package`](https://github.com/jaywcjlove/github-action-package) | 修改 JSON 文件内容
|
||||
[`markdown-to-html-cli`](https://github.com/jaywcjlove/markdown-to-html-cli) | Markdown 转换成 HTML
|
||||
[`ncipollo/release-action`](https://github.com/ncipollo/release-action) | 创建 `Release`
|
||||
[`peaceiris/actions-gh-pages`](https://github.com/peaceiris/actions-gh-pages) | 将文件或文件夹内容提交到 `gh-pages` 分支
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
|
@ -38,6 +38,7 @@ export HOMEBREW_INSTALL_FROM_API=1
|
||||
命令 | 说明
|
||||
:--- :---
|
||||
`brew install git` | `安装`一个包
|
||||
`brew reinstall git` | 重新`安装`一个包
|
||||
`brew uninstall git` | `删除`/`卸载`软件包
|
||||
`brew upgrade git` | 升级包
|
||||
:--- :---
|
||||
@ -46,9 +47,6 @@ export HOMEBREW_INSTALL_FROM_API=1
|
||||
`brew switch git 2.5.0` | 更改版本
|
||||
:--- :---
|
||||
`brew list --versions git` | 看看你有什么版本
|
||||
:--- :---
|
||||
`brew help` | 打印帮助信息
|
||||
`brew help <sub-command>` | 打印子命令的帮助信息
|
||||
|
||||
### 更多包命令
|
||||
|
||||
@ -119,6 +117,13 @@ $ brew search <text>
|
||||
$ brew info <formula>
|
||||
```
|
||||
|
||||
### 帮助命令
|
||||
|
||||
命令 | 说明
|
||||
:--- :---
|
||||
`brew help` | 打印帮助信息
|
||||
`brew help <sub-command>` | 打印子命令的帮助信息
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
|
@ -8,11 +8,11 @@ HTTP 状态码
|
||||
|
||||
### Means
|
||||
|
||||
- [1xx: Informational](#1xx-information) _这意味着已收到请求并且该过程正在继续_<!--rehype:tooltips-->
|
||||
- [2xx: Success](#2xx-successful) _这意味着该操作已成功接收、理解和接受_<!--rehype:tooltips-->
|
||||
- [3xx: Redirection](#3xx-redirection) _这意味着必须采取进一步行动才能完成请求_<!--rehype:tooltips-->
|
||||
- [4xx: Client Error](#4xx-client-error) _这意味着请求包含不正确的语法或无法完成_<!--rehype:tooltips-->
|
||||
- [5xx: Server Error](#5xx-server-error) _这意味着服务器未能满足明显有效的请求_<!--rehype:tooltips-->
|
||||
- [1xx: Informational](#1xx-信息) _这意味着已收到请求并且该过程正在继续_<!--rehype:tooltips-->
|
||||
- [2xx: Success](#2xx-成功的) _这意味着该操作已成功接收、理解和接受_<!--rehype:tooltips-->
|
||||
- [3xx: Redirection](#3xx-重定向) _这意味着必须采取进一步行动才能完成请求_<!--rehype:tooltips-->
|
||||
- [4xx: Client Error](#4xx-客户端错误) _这意味着请求包含不正确的语法或无法完成_<!--rehype:tooltips-->
|
||||
- [5xx: Server Error](#5xx-服务器错误) _这意味着服务器未能满足明显有效的请求_<!--rehype:tooltips-->
|
||||
|
||||
### 2xx. 成功的
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
185
docs/ini.md
Normal file
185
docs/ini.md
Normal file
@ -0,0 +1,185 @@
|
||||
INI 备忘清单
|
||||
====
|
||||
|
||||
这是理解和编写 INI 格式配置文件的快速参考备忘单,此清单包含配置的内容,结构和语法等内容。
|
||||
|
||||
入门
|
||||
------
|
||||
|
||||
### 介绍
|
||||
|
||||
INI 是一种固定标准格式的配置文件,INI配置方法来自 MS-DOS 操作系统
|
||||
|
||||
```ini
|
||||
; 这里是注释
|
||||
[owner]
|
||||
name=John Doe
|
||||
organization=Acme Products
|
||||
|
||||
[database]
|
||||
; 这里是注释
|
||||
server=192.0.2.42
|
||||
port=143
|
||||
file="acme payroll.dat"
|
||||
```
|
||||
|
||||
现在已成为许多配置的非正式标准,其它操作系统可能使用 `.conf` 或 `.cfg` 作为后缀
|
||||
|
||||
### 稳定的特性
|
||||
|
||||
- 基本元素是键或属性
|
||||
- 每个键由`名称`和`值`构成,等号 (=) 分隔
|
||||
- `键名称`显示在等号的`左侧`
|
||||
- `等号`和`分号`是`保留`字符
|
||||
<!--rehype:className=style-round-->
|
||||
|
||||
```ini
|
||||
name = value
|
||||
```
|
||||
|
||||
与下面👇 JSON 大致相同
|
||||
|
||||
```js
|
||||
{
|
||||
"name": "value"
|
||||
}
|
||||
```
|
||||
|
||||
### 注释
|
||||
|
||||
注释 (`;`)
|
||||
|
||||
```ini
|
||||
; 这里是注释文本,将被忽略
|
||||
```
|
||||
|
||||
注释 (`#`)
|
||||
|
||||
```ini
|
||||
# 这里是注释文本,⚠️ 部分编译器支持
|
||||
```
|
||||
|
||||
一行之后的注释 (`;`,`#`) _(不标准)_
|
||||
|
||||
```ini
|
||||
var = a ; 这是一个内联注释
|
||||
foo = bar # 这是另一个内联注释
|
||||
```
|
||||
|
||||
在某些情况下注释必须单独出现在行上
|
||||
|
||||
### 部分(Sections)
|
||||
|
||||
- 名称单独出现在一行中
|
||||
- 名称在方括号 `[` 和 `]` 中
|
||||
- 没有明确的 `section 结束` 分隔符
|
||||
- 在下一个 `section` 声明处或文件末尾处结束
|
||||
- 部分和属性名称不区分大小写
|
||||
<!--rehype:className=style-round-->
|
||||
|
||||
```ini
|
||||
[section]
|
||||
key1 = a
|
||||
key2 = b
|
||||
```
|
||||
|
||||
与下面👇 `JSON` 大致相同
|
||||
|
||||
```json
|
||||
{
|
||||
"section": {
|
||||
"key1": "a",
|
||||
"key2": "b"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 嵌套(部分解析器支持)
|
||||
|
||||
```ini
|
||||
[section]
|
||||
domain = jaywcjlove.github.io
|
||||
|
||||
[section.subsection]
|
||||
foo = bar
|
||||
```
|
||||
|
||||
与下面👇 `JSON` 大致相同
|
||||
|
||||
```js
|
||||
{
|
||||
"section": {
|
||||
"domain": "jaywcjlove.github.io"
|
||||
"subsection": {
|
||||
"foo": "bar"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
嵌套到上一节(简写)
|
||||
|
||||
```ini
|
||||
[section]
|
||||
domain = jaywcjlove.github.io
|
||||
[.subsection]
|
||||
foo = bar
|
||||
```
|
||||
|
||||
### 转义字符
|
||||
|
||||
序列 | 意思
|
||||
:- | :-
|
||||
`\\` | \ (单个反斜杠,转义转义字符)
|
||||
`\'` | 撇号
|
||||
`\"` | 双引号
|
||||
`\0` | 空字符
|
||||
`\a` | 铃声/警报/声音
|
||||
`\b` | 退格键,某些应用程序的[贝尔字符](https://en.wikipedia.org/wiki/Bell_character)
|
||||
`\t` | 制表符
|
||||
`\r` | 回车
|
||||
`\n` | 换行
|
||||
`\;` | 分号
|
||||
`\#` | 数字符号
|
||||
`\=` | 等号
|
||||
`\:` | 冒号
|
||||
`\x????` | 十六进制代码点的 Unicode 字符对应于 ????
|
||||
|
||||
### 数组
|
||||
|
||||
```ini
|
||||
[section]
|
||||
domain = jaywcjlove.github.io
|
||||
array[]=first value
|
||||
array[]=second value
|
||||
```
|
||||
|
||||
与下面👇 `JSON` 大致相同
|
||||
|
||||
```js
|
||||
{
|
||||
"section": {
|
||||
"domain": "jaywcjlove.github.io",
|
||||
"array": [
|
||||
"first value", "second value"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 解释器
|
||||
|
||||
- [@go-ini/ini](https://github.com/go-ini/ini) _(golang)_
|
||||
- [@npm/ini](https://www.npmjs.com/package/ini) _(nodejs)_
|
||||
- [@zonyitoo/rust-ini](https://github.com/zonyitoo/rust-inii) _(rust)_
|
||||
- [@rxi/ini](https://www.npmjs.com/package/ini) _(c)_
|
||||
- [@pulzed/mINI](https://github.com/pulzed/mINI) _(c++)_
|
||||
- [@rickyah/ini-parser](https://github.com/rickyah/ini-parser) _(c#)_
|
||||
- [@Enichan/Ini](https://github.com/Enichan/Ini) _(c#)_
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
- [INI 文件配置](https://en.wikipedia.org/wiki/INI_file) _(wikipedia.org)_
|
||||
- [YAML 格式配置文件备忘清单](./yaml.md) _(jaywcjlove.github.io)_
|
||||
- [TOML 格式配置文件备忘清单](./toml.md) _(jaywcjlove.github.io)_
|
605
docs/mysql.md
Normal file
605
docs/mysql.md
Normal file
@ -0,0 +1,605 @@
|
||||
MySQL 备忘清单
|
||||
===
|
||||
|
||||
本备忘单旨在快速理解 [MySQL](https://mysql.com) 所涉及的主要概念,提供了最常用的SQL语句,供您参考。
|
||||
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### 介绍
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
MySQL 为关系型数据库(Relational Database Management System),一个关系型数据库由一个或数个表格组成,如下所示的一个表格
|
||||
|
||||
----
|
||||
|
||||
```bash
|
||||
name ▼ 键 ▼ 列(col)
|
||||
┌┈┈┈┈┬┈┈┈┈┈┈┈┈┬┈┈┈┈┈┈┬┈┈┈┈┈┈┈┐
|
||||
┆ id ┆ name ┆ uid ┆ level ┆ ◀ 表头header
|
||||
├┈┈┈┈┼┈┈┈┈┈┈┈┈┤┈┈┈┈┈┈┤┈┈┈┈┈┈┈┤
|
||||
┆ 1 ┆ mysql ┆ 0 ┆ 3 ┆
|
||||
├┈┈┈┈┼┈┈┈┈┈┈┈┈┤┈┈┈┈┈┈┤┈┈┈┈┈┈┈┤
|
||||
┆ 2 ┆ redis ┆ 12 ┆ 1 ┆ ◀ 行 row
|
||||
└┈┈┈┈┴┈┈┈┈┈┈┈┈┴┈┈┈┈┈┈┴┈┈┈┈┈┈┈┘
|
||||
redis ▲ 值
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
- `表头(header)` 每一列的名称
|
||||
- `列(col)` 具有相同数据类型的数据的集合
|
||||
- `行(row)` 每一行用来描述某个人/物的具体信息
|
||||
- `值(value)` 行的具体信息,每个值与该列数据类型相同
|
||||
- `键(key)` 用来识别某个特定的人/物的方法,有唯一性
|
||||
|
||||
### 登录MySQL
|
||||
|
||||
```shell
|
||||
# 默认用户名<root>,-p 是密码,
|
||||
# ⚠️参数后面不需要空格
|
||||
mysql -h 127.0.0.1 -u <用户名> -p<密码>
|
||||
mysql -D 数据库名 -h 主机名 -u 用户名 -p
|
||||
mysql -h <host> -P <端口号> -u <user> -p [db_name]
|
||||
mysql -h <host> -u <user> -p [db_name]
|
||||
```
|
||||
|
||||
### 常用的
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
#### 数据库 Database
|
||||
|
||||
:-|:-
|
||||
:-|:-
|
||||
`CREATE DATABASE` db `;` | `创建`数据库
|
||||
`SHOW DATABASES;` | `列出`数据库
|
||||
`USE` db`;` | `切换`到数据库
|
||||
`CONNECT` db `;` | `切换`到数据库
|
||||
`DROP DATABASE` db`;` | `删除`数据库
|
||||
|
||||
#### 表 Table
|
||||
|
||||
:-|:-
|
||||
:-|:-
|
||||
`SHOW TABLES;` | 列出当前数据库的表
|
||||
`SHOW FIELDS FROM` t`;` | 表的列表字段
|
||||
`DESC` t`;` | 显示表格结构
|
||||
`SHOW CREATE TABLE `t`;` | 显示创建表sql
|
||||
`TRUNCATE TABLE `t`;` | 删除表中的所有数据
|
||||
`DROP TABLE `t`;` | 删除表格
|
||||
|
||||
#### Proccess
|
||||
|
||||
:-|:-
|
||||
:-|:-
|
||||
`show processlist;` | 列出进程
|
||||
`kill` pid`;` | 杀死进程
|
||||
|
||||
### 查看 MySQL 信息
|
||||
|
||||
```shell
|
||||
# 显示当前mysql的version的各种信息
|
||||
mysql> status;
|
||||
# 显示当前mysql的version信息
|
||||
mysql> select version();
|
||||
# 查看 MySQL 端口号
|
||||
mysql> show global variables like 'port';
|
||||
```
|
||||
|
||||
### 退出MySQL会话
|
||||
|
||||
```bash
|
||||
mysql> exit
|
||||
```
|
||||
|
||||
退出 `quit;` 或 `\q;` 一样的效果
|
||||
|
||||
### 备份
|
||||
|
||||
创建备份
|
||||
|
||||
```sql
|
||||
mysqldump -u user -p db_name > db.sql
|
||||
```
|
||||
|
||||
导出不带架构的数据库
|
||||
|
||||
```shell
|
||||
mysqldump -u user -p db_name --no-data=true --add-drop-table=false > db.sql
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
恢复备份
|
||||
|
||||
```shell
|
||||
mysql -u user -p db_name < db.sql
|
||||
```
|
||||
|
||||
MySQL 示例
|
||||
------
|
||||
|
||||
### 管理表格
|
||||
|
||||
创建一个包含三列的新表
|
||||
|
||||
```sql
|
||||
CREATE TABLE t (
|
||||
id INT,
|
||||
name VARCHAR DEFAULT NOT NULL,
|
||||
price INT DEFAULT 0
|
||||
PRIMARY KEY(id)
|
||||
);
|
||||
```
|
||||
|
||||
从数据库中删除表
|
||||
|
||||
```sql
|
||||
DROP TABLE t ;
|
||||
```
|
||||
|
||||
向表中添加新列
|
||||
|
||||
```sql
|
||||
ALTER TABLE t ADD column;
|
||||
```
|
||||
|
||||
从表中删除列c
|
||||
|
||||
```sql
|
||||
ALTER TABLE t DROP COLUMN c ;
|
||||
```
|
||||
|
||||
添加约束
|
||||
|
||||
```sql
|
||||
ALTER TABLE t ADD constraint;
|
||||
```
|
||||
|
||||
删除约束
|
||||
|
||||
```sql
|
||||
ALTER TABLE t DROP constraint;
|
||||
```
|
||||
|
||||
将表从t1重命名为t2
|
||||
|
||||
```sql
|
||||
ALTER TABLE t1 RENAME TO t2;
|
||||
```
|
||||
|
||||
将列c1重命名为c2
|
||||
|
||||
```sql
|
||||
ALTER TABLE t1 RENAME c1 TO c2 ;
|
||||
```
|
||||
|
||||
删除表中的所有数据
|
||||
|
||||
```sql
|
||||
TRUNCATE TABLE t;
|
||||
```
|
||||
|
||||
### 从表中查询数据
|
||||
|
||||
从表中查询列c1、c2中的数据
|
||||
|
||||
```sql
|
||||
SELECT c1, c2 FROM t
|
||||
```
|
||||
|
||||
查询表中的所有行和列
|
||||
|
||||
```sql
|
||||
SELECT * FROM t
|
||||
```
|
||||
|
||||
查询数据并使用条件筛选行
|
||||
|
||||
```sql
|
||||
SELECT c1, c2 FROM t
|
||||
WHERE condition
|
||||
```
|
||||
|
||||
查询表中的不同行
|
||||
|
||||
```sql
|
||||
SELECT DISTINCT c1 FROM t
|
||||
WHERE condition
|
||||
```
|
||||
|
||||
按升序或降序对结果集排序
|
||||
|
||||
```sql
|
||||
SELECT c1, c2 FROM t
|
||||
ORDER BY c1 ASC [DESC]
|
||||
```
|
||||
|
||||
跳过行的偏移并返回下n行
|
||||
|
||||
```sql
|
||||
SELECT c1, c2 FROM t
|
||||
ORDER BY c1
|
||||
LIMIT n OFFSET offset
|
||||
```
|
||||
|
||||
使用聚合函数对行进行分组
|
||||
|
||||
```sql
|
||||
SELECT c1, aggregate(c2)
|
||||
FROM t
|
||||
GROUP BY c1
|
||||
```
|
||||
|
||||
使用HAVING子句筛选组
|
||||
|
||||
```sql
|
||||
SELECT c1, aggregate(c2)
|
||||
FROM t
|
||||
GROUP BY c1
|
||||
HAVING condition
|
||||
```
|
||||
|
||||
### 从多个表查询
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
内部连接 t1 和 t2
|
||||
|
||||
```sql
|
||||
SELECT c1, c2
|
||||
FROM t1
|
||||
INNER JOIN t2 ON condition
|
||||
```
|
||||
|
||||
左连接t1和t1
|
||||
|
||||
```sql
|
||||
SELECT c1, c2
|
||||
FROM t1
|
||||
LEFT JOIN t2 ON condition
|
||||
```
|
||||
|
||||
右连接t1和t2
|
||||
|
||||
```sql
|
||||
SELECT c1, c2
|
||||
FROM t1
|
||||
RIGHT JOIN t2 ON condition
|
||||
```
|
||||
|
||||
执行完全外部连接
|
||||
|
||||
```sql
|
||||
SELECT c1, c2
|
||||
FROM t1
|
||||
FULL OUTER JOIN t2 ON condition
|
||||
```
|
||||
|
||||
生成表中行的笛卡尔积
|
||||
|
||||
```sql
|
||||
SELECT c1, c2
|
||||
FROM t1
|
||||
CROSS JOIN t2
|
||||
```
|
||||
|
||||
执行交叉连接的另一种方法
|
||||
|
||||
```sql
|
||||
SELECT c1, c2
|
||||
FROM t1, t2
|
||||
```
|
||||
|
||||
使用INNER Join子句将t1连接到自身
|
||||
|
||||
```sql
|
||||
SELECT c1, c2
|
||||
FROM t1 A
|
||||
INNER JOIN t1 B ON condition
|
||||
```
|
||||
|
||||
使用SQL运算符,合并两个查询中的行
|
||||
|
||||
```sql
|
||||
SELECT c1, c2 FROM t1
|
||||
UNION [ALL]
|
||||
SELECT c1, c2 FROM t2
|
||||
```
|
||||
|
||||
返回两个查询的交集
|
||||
|
||||
```sql
|
||||
SELECT c1, c2 FROM t1
|
||||
INTERSECT
|
||||
SELECT c1, c2 FROM t2
|
||||
```
|
||||
|
||||
从另一个结果集中减去一个结果集
|
||||
|
||||
```sql
|
||||
SELECT c1, c2 FROM t1
|
||||
MINUS
|
||||
SELECT c1, c2 FROM t2
|
||||
```
|
||||
|
||||
使用模式匹配%查询行_
|
||||
|
||||
```sql
|
||||
SELECT c1, c2 FROM t1
|
||||
WHERE c1 [NOT] LIKE pattern
|
||||
```
|
||||
|
||||
查询列表中的行
|
||||
|
||||
```sql
|
||||
SELECT c1, c2 FROM t
|
||||
WHERE c1 [NOT] IN value_list
|
||||
```
|
||||
|
||||
查询两个值之间的行
|
||||
|
||||
```sql
|
||||
SELECT c1, c2 FROM t
|
||||
WHERE c1 BETWEEN low AND high
|
||||
```
|
||||
|
||||
检查表中的值是否为NULL
|
||||
|
||||
```sql
|
||||
SELECT c1, c2 FROM t
|
||||
WHERE c1 IS [NOT] NULL
|
||||
```
|
||||
|
||||
### 使用 SQL 约束
|
||||
|
||||
将c1和c2设置为主键
|
||||
|
||||
```sql
|
||||
CREATE TABLE t(
|
||||
c1 INT, c2 INT, c3 VARCHAR,
|
||||
PRIMARY KEY (c1,c2)
|
||||
);
|
||||
```
|
||||
|
||||
将c2列设置为外键
|
||||
|
||||
```sql
|
||||
CREATE TABLE t1(
|
||||
c1 INT PRIMARY KEY,
|
||||
c2 INT,
|
||||
FOREIGN KEY (c2) REFERENCES t2(c2)
|
||||
);
|
||||
```
|
||||
|
||||
使c1和c2中的值唯一
|
||||
|
||||
```sql
|
||||
CREATE TABLE t(
|
||||
c1 INT, c1 INT,
|
||||
UNIQUE(c2,c3)
|
||||
);
|
||||
```
|
||||
|
||||
确保c1>0和c1>=c2中的值
|
||||
|
||||
```sql
|
||||
CREATE TABLE t(
|
||||
c1 INT, c2 INT,
|
||||
CHECK(c1> 0 AND c1 >= c2)
|
||||
);
|
||||
```
|
||||
c2列中的设置值不为NULL
|
||||
|
||||
```sql
|
||||
CREATE TABLE t(
|
||||
c1 INT PRIMARY KEY,
|
||||
c2 VARCHAR NOT NULL
|
||||
);
|
||||
```
|
||||
|
||||
### 修改数据
|
||||
|
||||
在表格中插入一行
|
||||
|
||||
```sql
|
||||
INSERT INTO t(column_list)
|
||||
VALUES(value_list);
|
||||
```
|
||||
|
||||
在表格中插入多行
|
||||
|
||||
```sql
|
||||
INSERT INTO t(column_list)
|
||||
VALUES (value_list),
|
||||
(value_list), …;
|
||||
```
|
||||
|
||||
将行从t2插入t1
|
||||
|
||||
```sql
|
||||
INSERT INTO t1(column_list)
|
||||
SELECT column_list
|
||||
FROM t2;
|
||||
```
|
||||
|
||||
更新列c1中所有行的新值
|
||||
|
||||
```sql
|
||||
UPDATE t
|
||||
SET c1 = new_value;
|
||||
```
|
||||
|
||||
更新列c1、c2中与条件匹配的值
|
||||
|
||||
```sql
|
||||
UPDATE t
|
||||
SET c1 = new_value,
|
||||
c2 = new_value
|
||||
WHERE condition;
|
||||
```
|
||||
|
||||
删除表中的所有数据
|
||||
|
||||
```sql
|
||||
DELETE FROM t;
|
||||
```
|
||||
|
||||
删除表中的行子集
|
||||
|
||||
```sql
|
||||
DELETE FROM t
|
||||
WHERE condition;
|
||||
```
|
||||
|
||||
### 管理视图
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
创建由c1和c2组成的新视图
|
||||
|
||||
```sql
|
||||
CREATE VIEW v(c1,c2)
|
||||
AS
|
||||
SELECT c1, c2
|
||||
FROM t;
|
||||
```
|
||||
|
||||
使用选中选项创建新视图
|
||||
|
||||
```sql
|
||||
CREATE VIEW v(c1,c2)
|
||||
AS
|
||||
SELECT c1, c2
|
||||
FROM t;
|
||||
WITH [CASCADED | LOCAL] CHECK OPTION;
|
||||
```
|
||||
|
||||
创建递归视图
|
||||
|
||||
```sql
|
||||
CREATE RECURSIVE VIEW v
|
||||
AS
|
||||
select-statement -- anchor part
|
||||
UNION [ALL]
|
||||
select-statement; -- recursive part
|
||||
```
|
||||
|
||||
创建临时视图
|
||||
|
||||
```sql
|
||||
CREATE TEMPORARY VIEW v
|
||||
AS
|
||||
SELECT c1, c2
|
||||
FROM t;
|
||||
```
|
||||
|
||||
删除视图
|
||||
|
||||
```sql
|
||||
DROP VIEW view_name;
|
||||
```
|
||||
|
||||
### 管理触发器
|
||||
|
||||
创建或修改触发器
|
||||
|
||||
```sql
|
||||
CREATE OR MODIFY TRIGGER trigger_name
|
||||
WHEN EVENT
|
||||
ON table_name TRIGGER_TYPE
|
||||
EXECUTE stored_procedure;
|
||||
```
|
||||
|
||||
#### WHEN
|
||||
|
||||
:-|:-
|
||||
:-|:-
|
||||
`BEFORE` | 在事件发生前调用
|
||||
`AFTER` | 事件发生后调用
|
||||
|
||||
#### EVENT
|
||||
|
||||
:-|:-
|
||||
:-|:-
|
||||
`INSERT` | 为INSERT调用
|
||||
`UPDATE` | 调用UPDATE
|
||||
`DELETE` | 调用DELETE
|
||||
|
||||
#### TRIGGER_TYPE
|
||||
|
||||
:-|:-
|
||||
:-|:-
|
||||
`FOR EACH ROW` | -
|
||||
`FOR EACH STATEMENT` | -
|
||||
|
||||
### 管理索引
|
||||
|
||||
在t表的c1和c2上创建索引
|
||||
|
||||
```sql
|
||||
CREATE INDEX idx_name
|
||||
ON t(c1,c2);
|
||||
```
|
||||
|
||||
在t表的c3、c4上创建唯一索引
|
||||
|
||||
```sql
|
||||
CREATE UNIQUE INDEX idx_name
|
||||
ON t(c3,c4)
|
||||
```
|
||||
|
||||
删除索引
|
||||
|
||||
```sql
|
||||
DROP INDEX idx_name;
|
||||
```
|
||||
|
||||
MySQL 数据类型
|
||||
---------
|
||||
|
||||
|
||||
### Strings
|
||||
|
||||
| - | - |
|
||||
|--------------|-----------------------------|
|
||||
| `CHAR` | String (0 - 255) |
|
||||
| `VARCHAR` | String (0 - 255) |
|
||||
| `TINYTEXT` | String (0 - 255) |
|
||||
| `TEXT` | String (0 - 65535) |
|
||||
| `BLOB` | String (0 - 65535) |
|
||||
| `MEDIUMTEXT` | String (0 - 16777215) |
|
||||
| `MEDIUMBLOB` | String (0 - 16777215) |
|
||||
| `LONGTEXT` | String (0 - 4294967295) |
|
||||
| `LONGBLOB` | String (0 - 4294967295) |
|
||||
| `ENUM` | One of preset options |
|
||||
| `SET` | Selection of preset options |
|
||||
|
||||
|
||||
### Date & time
|
||||
| Data Type | Format |
|
||||
|-------------|---------------------|
|
||||
| `DATE ` | yyyy-MM-dd |
|
||||
| `TIME ` | hh:mm:ss |
|
||||
| `DATETIME ` | yyyy-MM-dd hh:mm:ss |
|
||||
| `TIMESTAMP` | yyyy-MM-dd hh:mm:ss |
|
||||
| `YEAR ` | yyyy |
|
||||
|
||||
|
||||
### Numeric
|
||||
|
||||
| - | - |
|
||||
|---------------|---------------------------------------------------------------|
|
||||
| `TINYINT x` | Integer (-128 to 127) |
|
||||
| `SMALLINT x` | Integer (-32768 to 32767) |
|
||||
| `MEDIUMINT x` | Integer (-8388608 to 8388607) |
|
||||
| `INT x` | Integer (-2147483648 to 2147483647) |
|
||||
| `BIGINT x` | Integer (-9223372036854775808 to 9223372036854775807) |
|
||||
| `FLOAT` | Decimal (precise to 23 digits) |
|
||||
| `DOUBLE` | Decimal (24 to 53 digits) |
|
||||
| `DECIMAL` | "DOUBLE" stored as string |
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
- [SQL 基础教程](http://www.w3school.com.cn/sql/index.asp) _(w3school.com.cn)_
|
||||
- [SQL 语句教程](http://www.1keydata.com/cn/sql/sql-count.php) _(1keydata.com)_
|
||||
- [21分钟 MySQL 基础入门](https://jaywcjlove.github.io/mysql-tutorial/21-minutes-MySQL-basic-entry.html) _(jaywcjlove.github.io)_
|
48
docs/npm.md
48
docs/npm.md
@ -21,6 +21,7 @@ npm 备忘清单
|
||||
| `npm install <package_name>@<tag>` | 使用 dist-tags 安装包 |
|
||||
| `npm install -g <package_name>` | 全局安装包 |
|
||||
| `npm uninstall <package_name>` | 卸载包 |
|
||||
<!--rehype:class=auto-wrap-->
|
||||
|
||||
`--save` 是 npm@5 的默认值。 以前,使用不带 `--save` 的 `npm install` 不会更新 package.json。
|
||||
|
||||
@ -40,6 +41,7 @@ npm 备忘清单
|
||||
| `npm i /path/to/repo` | 绝对路径 |
|
||||
| `npm i ./archive.tgz` | 压缩包 |
|
||||
| `npm i https://site.com/archive.tgz` | 通过 HTTP 压缩包 |
|
||||
<!--rehype:class=auto-wrap-->
|
||||
|
||||
### 清单
|
||||
|
||||
@ -49,6 +51,7 @@ npm 备忘清单
|
||||
| `npm list -g --depth 0` | 列出所有全局安装包的安装版本 |
|
||||
| `npm view` | 列出此软件中所有依赖项的最新版本 |
|
||||
| `npm outdated` | 仅列出此软件中已过时的依赖项 |
|
||||
<!--rehype:class=auto-wrap-->
|
||||
|
||||
### 更新
|
||||
|
||||
@ -105,7 +108,7 @@ npm access restricted <package-name>
|
||||
公开私有包
|
||||
|
||||
```bash
|
||||
npm access restricted <package-name>
|
||||
npm access public <package-name>
|
||||
```
|
||||
|
||||
授予私有包访问权限
|
||||
@ -167,7 +170,7 @@ npm publish --access public
|
||||
```ini
|
||||
# last modified: 01 Jan 2016
|
||||
; Set a new registry for a scoped package
|
||||
@myscope:registry=https://mycustomregistry.example.org
|
||||
@myscope:registry=https://registry.npmmirror.com
|
||||
```
|
||||
|
||||
注释使用 `#`, `;` 放置到一行的开头。`.npmrc` 文件由指定此注释语法的 [`npm/ini`](https://github.com/npm/ini) 解析
|
||||
@ -190,19 +193,21 @@ npm publish --access public
|
||||
`.npmignore` 文件就像 [`.gitignore`](./git.md#忽略文件) 一样工作。它不能覆盖 `package.json#files` 字段。
|
||||
|
||||
### 中国镜像站安装
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
```bash
|
||||
# 临时使用
|
||||
$ npm install -g <package-name> --registry=https://registry.npmmirror.com
|
||||
```
|
||||
|
||||
将配置放置在 `.npmrc` 配置文件中。
|
||||
将配置放置在 `.npmrc` 全局配置文件中,或者在项目的根目录中。
|
||||
|
||||
```ini
|
||||
; registry=https://registry.npmjs.org/
|
||||
registry=https://registry.npmmirror.com
|
||||
```
|
||||
|
||||
或者配置到 `package.json#publishConfig` 字段上
|
||||
或者配置到 [`package.json#publishConfig`](./package.json.md#publishconfig) 字段上
|
||||
|
||||
```json
|
||||
"publishConfig":{
|
||||
@ -210,4 +215,37 @@ registry=https://registry.npmmirror.com
|
||||
}
|
||||
```
|
||||
|
||||
替换 npm 仓库地址为 npmmirror(淘宝) 镜像地址
|
||||
|
||||
```bash
|
||||
npm config set registry https://registry.npmmirror.com
|
||||
```
|
||||
|
||||
请参阅:[npmmirror 中国镜像站](https://npmmirror.com/)
|
||||
|
||||
#### electronjs 镜像和缓存
|
||||
|
||||
```ini
|
||||
ELECTRON_MIRROR="https://npmmirror.com/mirrors/electron/"
|
||||
ELECTRON_BUILDER_BINARIES_MIRROR=https://npmmirror.com/mirrors/electron-builder-binaries/
|
||||
; ELECTRON_CUSTOM_DIR="{{ version }}"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 身份验证相关配置
|
||||
|
||||
```ini
|
||||
//registry.npmjs.org/:_authToken=MYTOKEN
|
||||
; 将适用于 @myorg 和 @another
|
||||
//somewhere.com/:_authToken=MYTOKEN
|
||||
; 将适用于 @myorg
|
||||
//somewhere.com/myorg/:_authToken=MYTOKEN1
|
||||
; 将适用于 @another
|
||||
//somewhere.com/another/:_authToken=MYTOKEN2
|
||||
```
|
||||
|
||||
另见
|
||||
----
|
||||
|
||||
- [npm 仓库、网站和命令行界面的文档](https://docs.npmjs.com/) _(npmjs.com)_
|
||||
- [npmmirror 中国镜像站](https://npmmirror.com/) _(npmmirror.com)_
|
@ -228,6 +228,16 @@ const school = <div>学校</div>;
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### HTML 代码预览
|
||||
|
||||
```
|
||||
```html preview
|
||||
这里是你的 HTML 代码
|
||||
\```
|
||||
```
|
||||
|
||||
上面的 `markdown` 代码在 `meta` 位置添加 `preview` 标识,HTML 代码将被执行预览
|
||||
|
||||
|
||||
布局
|
||||
---
|
||||
@ -602,6 +612,17 @@ H2 部分
|
||||
|
||||
`<!--rehype:className=style-list-arrow-->`
|
||||
|
||||
### 隐藏表头强制小尺寸自动换行
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`visualEffectState.inactive` | 后台应一直显示为非激活状态。
|
||||
`titleBarStyle` _string_ _(win/mac)_ | 窗口标题栏样式。默认值 _(default)_
|
||||
`titleBarStyle.default` | 分别返回 _mac_ 或者 _win_ 的标准标题栏
|
||||
<!--rehype:className=auto-wrap-->
|
||||
|
||||
`<!--rehype:className=auto-wrap-->`
|
||||
|
||||
列表
|
||||
---
|
||||
|
||||
|
@ -54,7 +54,6 @@ Semver 备忘清单
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 连字符范围
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
| 范围 | 描述 |
|
||||
| --- | --- |
|
||||
@ -80,6 +79,43 @@ Semver 备忘清单
|
||||
|
||||
如果左边是部分的(例如,`1.2`),则假定缺少的部分为`0`(例如,` 1.2.0`)。
|
||||
|
||||
### 有效的语义版本
|
||||
<!--rehype:wrap-class=row-span-4-->
|
||||
|
||||
```js
|
||||
0.0.4
|
||||
1.2.3
|
||||
10.20.30
|
||||
1.1.2-prerelease+meta
|
||||
1.1.2+meta
|
||||
1.1.2+meta-valid
|
||||
1.0.0-alpha
|
||||
1.0.0-beta
|
||||
1.0.0-alpha.beta
|
||||
1.0.0-alpha.beta.1
|
||||
1.0.0-alpha.1
|
||||
1.0.0-alpha0.valid
|
||||
1.0.0-alpha.0valid
|
||||
1.0.0-alpha-a.b-c-somethinglong+build.1-aef.1-its-okay
|
||||
1.0.0-rc.1+build.1
|
||||
2.0.0-rc.1+build.123
|
||||
1.2.3-beta
|
||||
10.2.3-DEV-SNAPSHOT
|
||||
1.2.3-SNAPSHOT-123
|
||||
1.0.0
|
||||
2.0.0
|
||||
1.1.7
|
||||
2.0.0+build.1848
|
||||
2.0.1-alpha.1227
|
||||
1.0.0-alpha+beta
|
||||
1.2.3----RC-SNAPSHOT.12.9.1--.12+788
|
||||
1.2.3----R-S.12.9.1--.12+meta
|
||||
1.2.3----RC-SNAPSHOT.12.9.1--.12
|
||||
1.0.0+0.build.1-rc.10000aaa-kk-0.1
|
||||
99999999999999999999999.999999999999999999.99999999999999999
|
||||
1.0.0-0A.is.legal
|
||||
```
|
||||
|
||||
### 组合范围
|
||||
|
||||
| 范围 | 描述 |
|
||||
@ -88,13 +124,8 @@ Semver 备忘清单
|
||||
| `0.14.x \|\| 15.x.x` | 或 (双竖线分隔) |
|
||||
<!--rehype:className=shortcuts show-header-->
|
||||
|
||||
### 预发布
|
||||
|
||||
```
|
||||
1.2.3-prerelease+build
|
||||
```
|
||||
|
||||
### 解释
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
| 范围 | 描述 |
|
||||
| --- | --- |
|
||||
@ -104,6 +135,13 @@ Semver 备忘清单
|
||||
| `1.x.x` | 表示定义了公共 API |
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 预发布
|
||||
|
||||
```
|
||||
1.2.3-prerelease+build
|
||||
1.1.2-prerelease+meta
|
||||
```
|
||||
|
||||
|
||||
另见
|
||||
----
|
||||
|
1209
docs/swiftui.md
Normal file
1209
docs/swiftui.md
Normal file
File diff suppressed because it is too large
Load Diff
12
docs/toml.md
12
docs/toml.md
@ -12,6 +12,7 @@ TOML 备忘清单
|
||||
|
||||
- [Document](https://toml.io/en/latest) _(toml.io)_
|
||||
- [Learn X in Y minutes](https://learnxinyminutes.com/docs/toml/) _(learnxinyminutes.com)_
|
||||
- [Better TOML VSCode 插件](https://marketplace.visualstudio.com/items?itemName=bungcip.better-toml) _(visualstudio.com)_
|
||||
|
||||
### 示例
|
||||
|
||||
@ -254,3 +255,14 @@ name = { first = "Tom", last = "Preston-Werner" }
|
||||
point = { x = 1, y = 2 }
|
||||
animal = { type.name = "pug" }
|
||||
```
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
- [Document](https://toml.io/en/latest) _(toml.io)_
|
||||
- [Learn X in Y minutes](https://learnxinyminutes.com/docs/toml/) _(learnxinyminutes.com)_
|
||||
- [Better TOML VSCode 插件](https://marketplace.visualstudio.com/items?itemName=bungcip.better-toml) _(visualstudio.com)_
|
||||
|
||||
|
||||
- [INI 格式配置文件备忘清单](./ini.md) _(jaywcjlove.github.io)_
|
||||
- [YAML 格式配置文件备忘清单](./yaml.md) _(jaywcjlove.github.io)_
|
271
docs/vue.md
Normal file
271
docs/vue.md
Normal file
@ -0,0 +1,271 @@
|
||||
Vue 3 备忘清单
|
||||
===
|
||||
|
||||
渐进式 JavaScript 框架 [Vue 3](https://cn.vuejs.org/) 备忘清单的快速参考列表,包含常用 API 和示例。
|
||||
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### 介绍
|
||||
|
||||
Vue 是一套用于构建用户界面的渐进式框架
|
||||
|
||||
- [Vue 3.x 官方文档](https://cn.vuejs.org/)
|
||||
- [Vue Router 4.x 官方文档](https://router.vuejs.org/zh/)
|
||||
<!--rehype:className=style-round-->
|
||||
|
||||
注意:Vue 3.x 版本对应 Vue Router 4.x 路由版本
|
||||
|
||||
### 创建应用
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
已安装 `16.0` 或更高版本的 Node.js
|
||||
|
||||
```bash
|
||||
$ npm init vue@latest
|
||||
```
|
||||
|
||||
指令将会安装并执行 [create-vue](https://www.npmjs.com/package/create-vue),它是 Vue 官方的项目脚手架工具
|
||||
|
||||
```bash
|
||||
✔ Project name: … <your-project-name>
|
||||
✔ Add TypeScript? … No/Yes
|
||||
✔ Add JSX Support? … No/Yes
|
||||
✔ Add Vue Router for Single Page Application development? … No/Yes
|
||||
✔ Add Pinia for state management? … No/Yes
|
||||
✔ Add Vitest for Unit testing? … No/Yes
|
||||
✔ Add Cypress for both Unit and End-to-End testing? … No/Yes
|
||||
✔ Add ESLint for code quality? … No/Yes
|
||||
✔ Add Prettier for code formatting? … No/Yes
|
||||
|
||||
Scaffolding project in ./<your-project-name>...
|
||||
Done.
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
安装依赖并启动开发服务器
|
||||
|
||||
```bash
|
||||
$ cd <your-project-name>
|
||||
$ npm install
|
||||
$ npm run dev
|
||||
```
|
||||
|
||||
当你准备将应用发布到生产环境时,请运行:
|
||||
|
||||
```bash
|
||||
$ npm run build
|
||||
```
|
||||
|
||||
此命令会在 `./dist` 文件夹中为你的应用创建一个生产环境的构建版本
|
||||
|
||||
### 应用实例
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```js
|
||||
import { createApp } from 'vue'
|
||||
|
||||
const app = createApp({
|
||||
data() {
|
||||
return { count: 0 }
|
||||
}
|
||||
})
|
||||
app.mount('#app')
|
||||
```
|
||||
|
||||
挂载应用
|
||||
|
||||
```html
|
||||
<div id="app">
|
||||
<button @click="count++">
|
||||
{{ count }}
|
||||
</button>
|
||||
</div>
|
||||
```
|
||||
|
||||
### 通过 CDN 使用 Vue
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
||||
<div id="app">{{ message }}</div>
|
||||
<script>
|
||||
const { createApp } = Vue
|
||||
createApp({
|
||||
data() {
|
||||
return {
|
||||
message: 'Hello Vue!'
|
||||
}
|
||||
}
|
||||
}).mount('#app')
|
||||
</script>
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 使用 ES 模块构建版本
|
||||
|
||||
```html
|
||||
<div id="app">{{ message }}</div>
|
||||
<script type="module">
|
||||
import { createApp } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js'
|
||||
createApp({
|
||||
data() {
|
||||
return {
|
||||
message: 'Hello Vue!'
|
||||
}
|
||||
}
|
||||
}).mount('#app')
|
||||
</script>
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
模板语法
|
||||
---
|
||||
|
||||
### 文本插值
|
||||
|
||||
```html
|
||||
<span>Message: {{ msg }}</span>
|
||||
```
|
||||
|
||||
使用的是 `Mustache` 语法 (即双大括号),每次 `msg` 属性更改时它也会同步更新
|
||||
|
||||
### 原始 HTML
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```html
|
||||
<p>Using text interpolation: {{ rawHtml }}</p>
|
||||
<p>Using v-html directive: <span v-html="rawHtml"></span></p>
|
||||
```
|
||||
|
||||
双大括号`{{}}`会将数据解释为纯文本,使用 `v-html` 指令,将插入 HTML
|
||||
|
||||
### Attribute 绑定
|
||||
|
||||
```html
|
||||
<div v-bind:id="dynamicId"></div>
|
||||
```
|
||||
|
||||
简写
|
||||
|
||||
```html
|
||||
<div :id="dynamicId"></div>
|
||||
```
|
||||
|
||||
### 布尔型 Attribute
|
||||
|
||||
```html
|
||||
<button :disabled="isButtonDisabled">
|
||||
Button
|
||||
</button>
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 动态绑定多个值
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```js
|
||||
data() {
|
||||
return {
|
||||
objectOfAttrs: {
|
||||
id: 'container',
|
||||
class: 'wrapper'
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
通过不带参数的 `v-bind`,你可以将它们绑定到单个元素上
|
||||
|
||||
```html
|
||||
<div v-bind="objectOfAttrs"></div>
|
||||
```
|
||||
|
||||
### 使用 JavaScript 表达式
|
||||
|
||||
```html
|
||||
{{ number + 1 }}
|
||||
{{ ok ? 'YES' : 'NO' }}
|
||||
{{ message.split('').reverse().join('') }}
|
||||
|
||||
<div :id="`list-${id}`"></div>
|
||||
```
|
||||
|
||||
### 仅支持表达式(例子都是无效)
|
||||
|
||||
```html
|
||||
<!-- 这是一个语句,而非表达式 -->
|
||||
{{ var a = 1 }}
|
||||
<!-- 条件控制也不支持,请使用三元表达式 -->
|
||||
{{ if (ok) { return message } }}
|
||||
```
|
||||
|
||||
### 调用函数
|
||||
|
||||
```html
|
||||
<span :title="toTitleDate(date)">
|
||||
{{ formatDate(date) }}
|
||||
</span>
|
||||
```
|
||||
|
||||
|
||||
### 指令 Directives
|
||||
|
||||
```html
|
||||
<p v-if="seen">Now you see me</p>
|
||||
```
|
||||
|
||||
### 参数 Arguments
|
||||
|
||||
```html
|
||||
<a v-bind:href="url"> ... </a>
|
||||
<!-- 简写 -->
|
||||
<a :href="url"> ... </a>
|
||||
```
|
||||
|
||||
### 绑定事件
|
||||
|
||||
```html
|
||||
<a v-on:click="doSomething"> ... </a>
|
||||
<!-- 简写 -->
|
||||
<a @click="doSomething"> ... </a>
|
||||
```
|
||||
|
||||
### 动态参数
|
||||
|
||||
```html
|
||||
<a v-bind:[attributeName]="url"> ... </a>
|
||||
<!-- 简写 -->
|
||||
<a :[attributeName]="url"> ... </a>
|
||||
```
|
||||
|
||||
这里的 `attributeName` 会作为一个 JS 表达式被动态执行
|
||||
|
||||
### 动态的事件名称
|
||||
|
||||
```html
|
||||
<a v-on:[eventName]="doSomething"> ... </a>
|
||||
<!-- 简写 -->
|
||||
<a @[eventName]="doSomething">
|
||||
```
|
||||
|
||||
### 修饰符 Modifiers
|
||||
|
||||
```html
|
||||
<form @submit.prevent="onSubmit">
|
||||
...
|
||||
</form>
|
||||
```
|
||||
|
||||
`.prevent` 修饰符会告知 `v-on` 指令对触发的事件调用 `event.preventDefault()`
|
||||
|
||||
### 指令语法
|
||||
|
||||
```bash
|
||||
v-on:submit.prevent="onSubmit"
|
||||
──┬─ ─┬──── ─┬───── ─┬──────
|
||||
┆ ┆ ┆ ╰─ Value 解释为JS表达式
|
||||
┆ ┆ ╰─ Modifiers 由前导点表示
|
||||
┆ ╰─ Argument 跟随冒号或速记符号
|
||||
╰─ Name 以 v- 开头使用速记时可以省略
|
||||
```
|
@ -1,7 +1,7 @@
|
||||
Vue2 备忘清单
|
||||
===
|
||||
|
||||
渐进式 JavaScript 框架 Vue 2 备忘清单的快速参考列表,包含常用 API 和示例。
|
||||
渐进式 JavaScript 框架 [Vue 2](https://v2.cn.vuejs.org/) 备忘清单的快速参考列表,包含常用 API 和示例。
|
||||
|
||||
入门
|
||||
---
|
||||
@ -14,6 +14,8 @@ Vue 是一套用于构建用户界面的渐进式框架
|
||||
- [Vue Router 3.x 官方文档](https://v3.router.vuejs.org/)
|
||||
<!--rehype:className=style-round-->
|
||||
|
||||
注意:Vue 2.x 版本对应 Vue Router 3.x 路由版本
|
||||
|
||||
#### 快速创建 **Vue** 项目 ([Vue CLI](https://cli.vuejs.org/zh/guide/creating-a-project.html))
|
||||
|
||||
```bash
|
||||
|
10
docs/yaml.md
10
docs/yaml.md
@ -426,9 +426,9 @@ YAML 参考
|
||||
`"` | 环绕内嵌转义标量
|
||||
`|` | 块标量指示器
|
||||
`>` | 折叠标量指示器
|
||||
`-` | 剥离 chomp 修饰符(`|-` 或 `>-`)
|
||||
`+` | 保留 chomp 修饰符(`|+` 或 `>+`)
|
||||
`1-9` | 显式缩进修饰符(`|1` 或 `>2`)。 <br/> 修饰符可以组合(`|2-`, `>+1`)
|
||||
`-` | 剥离 chomp 修饰符(`\|-` 或 `>-`)
|
||||
`+` | 保留 chomp 修饰符(`\|+` 或 `>+`)
|
||||
`1-9` | 显式缩进修饰符(`\|1` 或 `>2`)。 <br/> 修饰符可以组合(`\|2-`, `>+1`)
|
||||
|
||||
### 标签属性(通常未指定)
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
@ -441,6 +441,7 @@ YAML 参考
|
||||
`!!foo` | 次要的(按照惯例,表示 `tag:yaml.org,2002:foo`)
|
||||
`!h!foo` | 需要 `%TAG !h! <prefix>`(然后表示 `<prefix>foo`)
|
||||
`!<foo>` | 逐字标记(始终表示“foo”)
|
||||
<!--rehype:class=auto-wrap-->
|
||||
|
||||
### 杂项指标
|
||||
|
||||
@ -515,6 +516,7 @@ YAML 参考
|
||||
| `[.inf, -.Inf, .NAN]` | [无穷大(浮点数),负数,不是数字] |
|
||||
| `{Y, true, Yes, ON}` | 布尔真 |
|
||||
| `{n, FALSE, No, off}` | 布尔假 |
|
||||
<!--rehype:class=auto-wrap-->
|
||||
|
||||
另见
|
||||
---
|
||||
@ -522,3 +524,5 @@ YAML 参考
|
||||
- [YAML Reference Card](https://yaml.org/refcard.html) _(yaml.org)_
|
||||
- [Learn X in Y minutes](https://learnxinyminutes.com/docs/yaml/) _(learnxinyminutes.com)_
|
||||
- [YAML lint online](http://www.yamllint.com/) _(yamllint.com)_
|
||||
- [INI 格式配置文件备忘清单](./ini.md) _(jaywcjlove.github.io)_
|
||||
- [TOML 格式配置文件备忘清单](./toml.md) _(jaywcjlove.github.io)_
|
16
package.json
16
package.json
@ -1,31 +1,39 @@
|
||||
{
|
||||
"name": "@wcj/reference",
|
||||
"version": "1.8.0",
|
||||
"version": "1.11.1",
|
||||
"description": "为开发人员分享快速参考备忘单(主要是方便自己)。",
|
||||
"author": "jaywcjlove",
|
||||
"license": "MIT",
|
||||
"homepage": "https://jaywcjlove.github.io/reference",
|
||||
"private": false,
|
||||
"scripts": {
|
||||
"prepare": "husky install",
|
||||
"build": "node scripts/build.mjs",
|
||||
"start": "node scripts/watch.mjs"
|
||||
"start": "node scripts/watch.mjs",
|
||||
"prettier": "prettier --write '**/*.{mjs,css,json,prettierrc,lintstagedrc}'"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jaywcjlove/reference.git"
|
||||
"url": "https://github.com/jaywcjlove/reference.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jaywcjlove/reference/issues"
|
||||
},
|
||||
"keywords": [],
|
||||
"devDependencies": {
|
||||
"@wcj/markdown-to-html": "^2.1.0",
|
||||
"@wcj/markdown-to-html": "^2.1.1",
|
||||
"chokidar": "^3.5.3",
|
||||
"fs-extra": "^10.1.0",
|
||||
"husky": "^8.0.1",
|
||||
"lint-staged": "^13.0.3",
|
||||
"prettier": "^2.7.1",
|
||||
"recursive-readdir-files": "^2.3.0",
|
||||
"rehype-autolink-headings": "^6.1.1",
|
||||
"rehype-document": "^6.1.0",
|
||||
"rehype-slug": "^5.0.1",
|
||||
"remark-gemoji": "^7.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
}
|
||||
}
|
||||
|
3
scripts/assets/menu.svg
Normal file
3
scripts/assets/menu.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg aria-hidden="true" fill="currentColor" height="1em" width="1em" viewBox="0 0 16 16" version="1.1" data-view-component="true">
|
||||
<path fill-rule="evenodd" d="M2 4a1 1 0 100-2 1 1 0 000 2zm3.75-1.5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zM3 8a1 1 0 11-2 0 1 1 0 012 0zm-1 6a1 1 0 100-2 1 1 0 000 2z"></path>
|
||||
</svg>
|
After Width: | Height: | Size: 416 B |
2
scripts/assets/mysql.svg
Normal file
2
scripts/assets/mysql.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 5.8 KiB |
3
scripts/assets/swiftui.svg
Normal file
3
scripts/assets/swiftui.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="1em" height="1em" viewBox="0 0 150 150">
|
||||
<path d="M149.996652,41.5504118 C149.996652,40.0404009 149.969865,38.5370862 149.929684,37.0237271 C149.889479,33.7232863 149.600703,30.4305622 149.065807,27.1735006 C148.507382,23.9127729 147.466929,20.7532587 145.978615,17.7987099 C142.956518,11.8649909 138.1316,7.04156844 132.19675,4.0211156 C129.242865,2.53082012 126.082821,1.49033249 122.821331,0.934130935 C119.563242,0.396319522 116.269046,0.106431705 112.967097,0.066962791 C111.456985,0.0267851164 109.953569,0.0100444187 108.440109,0 L41.5565427,0 C40.0464306,0 38.5430153,0.0267851164 37.0295549,0.066962791 C36.2092058,0.0903997679 35.3855083,0.117184884 34.5618108,0.157362559 C32.0854761,0.256798914 29.6181641,0.516263128 27.1753203,0.934130935 C24.7417426,1.35877149 22.3608012,2.04348485 20.0734408,2.97649606 C19.3010849,3.30014955 18.5410063,3.64835606 17.7932051,4.0211156 C15.5863952,5.15055914 13.519722,6.53499141 11.6355641,8.14602353 C11.0060717,8.68507399 10.4000179,9.2442133 9.81740256,9.8200933 C7.47219368,12.1591083 5.51152349,14.8541431 4.00799143,17.8054061 C2.51889323,20.7596305 1.47840127,23.9192644 0.920800036,27.1801969 C0.390726031,30.4353902 0.106428217,33.7258611 0.0703156391,37.0237271 C0.0267869101,38.5337381 0.0100450913,40.0370527 0,41.5504118 L0,108.456284 C0,109.966295 0.0267869101,111.46961 0.0703156391,112.979621 C0.110229315,116.280076 0.39900748,119.572822 0.934193491,122.829848 C1.49106583,126.090961 2.53159273,129.250701 4.02138488,132.204638 C7.04518753,138.133686 11.8652306,142.95575 17.7932051,145.982233 C20.747852,147.46998 23.9076759,148.509267 27.1686236,149.065869 C30.4267126,149.60368 33.7209094,149.893568 37.0228582,149.933037 C38.5296219,149.973215 40.0363856,149.989956 41.549846,150 L108.446806,150 C109.956918,150 111.460333,149.973215 112.973793,149.933037 C116.276759,149.891708 119.571929,149.601833 122.831376,149.065869 C126.092204,148.508782 129.251957,147.469519 132.206795,145.982233 C138.136507,142.956565 142.95707,138.132809 145.978615,132.20129 C147.468407,129.247353 148.508934,126.087613 149.065807,122.826499 C149.603754,119.569766 149.893662,116.276895 149.933033,112.976273 C149.973213,111.46961 149.989955,109.962947 150,108.452936 L150,46.9241758 C149.996652,45.1329211 149.996652,43.3416665 149.996652,41.5504118 Z M126.598286,122.240575 C119.901558,109.206268 107.4356,112.440571 101.046922,115.721747 C100.471003,116.056561 99.8816911,116.391375 99.2890308,116.726189 L99.1483995,116.809893 C85.9223626,123.840986 68.1659896,124.356599 50.312514,116.682663 C35.779112,110.381458 23.4900254,99.8344883 15.0575919,86.4255262 C19.1601349,89.4606647 23.5534617,92.08168 28.1731327,94.2501283 C47.0445109,103.089217 66.0096433,102.449722 79.4030984,94.2501283 C60.3174249,79.5685364 44.3792134,60.4339189 32.161034,44.9588179 C29.8334165,42.2434232 27.7304143,39.3433109 25.8728068,36.2871364 C40.5051565,49.6796946 63.6088665,66.4940515 71.9061119,71.1479654 C54.3037636,52.5691391 38.7941426,29.6511239 39.5207375,30.3877146 C67.2418412,58.3178947 92.819992,74.1110689 92.819992,74.1110689 C93.7843207,74.640075 94.4941738,75.0652887 95.0734408,75.4503248 C95.6092689,74.0835027 96.0741937,72.6899392 96.4663601,71.2751948 C100.892897,55.0936363 95.9105317,36.5951653 84.6432876,21.3209527 C110.355373,36.7491797 125.553596,66.075534 119.32564,90.8785518 C119.178312,91.45778 119.007545,92.0169193 118.843475,92.5827548 C131.741372,108.452936 128.232287,125.451441 126.588241,122.243923 L126.598286,122.240575 Z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 3.5 KiB |
4
scripts/assets/vue.svg
Normal file
4
scripts/assets/vue.svg
Normal file
@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24" height="1em" width="1em">
|
||||
<path d="m12 12.765 5.592-9.437h-3.276L12 7.33v.002L9.688 3.328h-3.28z"/>
|
||||
<path d="M18.461 3.332 12 14.235 5.539 3.332H1.992L12 20.672l10.008-17.34z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 269 B |
@ -1,3 +1,3 @@
|
||||
import { run } from './index.mjs';
|
||||
|
||||
run()
|
||||
run();
|
||||
|
@ -1,6 +1,7 @@
|
||||
import markdown from '@wcj/markdown-to-html';
|
||||
import rehypeDocument from 'rehype-document';
|
||||
import remarkGemoji from 'remark-gemoji';
|
||||
import rehypeRaw from 'rehype-raw';
|
||||
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
|
||||
import rehypeSlug from 'rehype-slug';
|
||||
import { htmlTagAddAttri } from './nodes/htmlTagAddAttri.mjs';
|
||||
@ -9,9 +10,10 @@ import { header } from './nodes/header.mjs';
|
||||
import { rehypeUrls } from './utils/rehypeUrls.mjs';
|
||||
import { tooltips } from './utils/tooltips.mjs';
|
||||
import { homeCardIcons } from './utils/homeCardIcons.mjs';
|
||||
import { getTocsTree } from './utils/getTocsTree.mjs';
|
||||
import { getTocsTree, getTocsTitleNode, getTocsTitleNodeWarpper, addTocsInWarp } from './utils/getTocsTree.mjs';
|
||||
import { rehypeTitle } from './utils/rehypeTitle.mjs';
|
||||
import { anchorPoint } from './utils/anchorPoint.mjs';
|
||||
import { rehypePreviewHTML } from './utils/rehypePreviewHTML.mjs';
|
||||
|
||||
const favicon = `data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20height%3D%221em%22%20width%3D%221em%22%3E%20%3Cpath%20d%3D%22m21.66%2010.44-.98%204.18c-.84%203.61-2.5%205.07-5.62%204.77-.5-.04-1.04-.13-1.62-.27l-1.68-.4c-4.17-.99-5.46-3.05-4.48-7.23l.98-4.19c.2-.85.44-1.59.74-2.2%201.17-2.42%203.16-3.07%206.5-2.28l1.67.39c4.19.98%205.47%203.05%204.49%207.23Z%22%20fill%3D%22%23c9d1d9%22%2F%3E%20%3Cpath%20d%3D%22M15.06%2019.39c-.62.42-1.4.77-2.35%201.08l-1.58.52c-3.97%201.28-6.06.21-7.35-3.76L2.5%2013.28c-1.28-3.97-.22-6.07%203.75-7.35l1.58-.52c.41-.13.8-.24%201.17-.31-.3.61-.54%201.35-.74%202.2l-.98%204.19c-.98%204.18.31%206.24%204.48%207.23l1.68.4c.58.14%201.12.23%201.62.27Zm2.43-8.88c-.06%200-.12-.01-.19-.02l-4.85-1.23a.75.75%200%200%201%20.37-1.45l4.85%201.23a.748.748%200%200%201-.18%201.47Z%22%20fill%3D%22%23228e6c%22%20%2F%3E%20%3Cpath%20d%3D%22M14.56%2013.89c-.06%200-.12-.01-.19-.02l-2.91-.74a.75.75%200%200%201%20.37-1.45l2.91.74c.4.1.64.51.54.91-.08.34-.38.56-.72.56Z%22%20fill%3D%22%23228e6c%22%20%2F%3E%20%3C%2Fsvg%3E`;
|
||||
|
||||
@ -19,8 +21,11 @@ export function create(str = '', options = {}) {
|
||||
let title = str.match(/[^===]+(?=[===])/g) || [];
|
||||
let description = str.match(/\n==={1,}\n+([\s\S]*?)\n/g) || [];
|
||||
title = title[0] || '';
|
||||
description = (description[0] || '').replace(/^\n[=\n]+/, '').replace(/\[([\s\S]*?)?\]\(([\s\S]*?)?\)/g, '$1').replace(/\n/, '');
|
||||
const subTitle = options.filename && !options.isHome ? `${options.filename} cheatsheet & `: ''
|
||||
description = (description[0] || '')
|
||||
.replace(/^\n[=\n]+/, '')
|
||||
.replace(/\[([\s\S]*?)?\]\(([\s\S]*?)?\)/g, '$1')
|
||||
.replace(/\n/, '');
|
||||
const subTitle = options.filename && !options.isHome ? `${options.filename} cheatsheet & ` : '';
|
||||
const mdOptions = {
|
||||
showLineNumbers: false,
|
||||
hastNode: false,
|
||||
@ -28,33 +33,53 @@ export function create(str = '', options = {}) {
|
||||
rehypePlugins: [
|
||||
rehypeSlug,
|
||||
rehypeAutolinkHeadings,
|
||||
[rehypeDocument, {
|
||||
[
|
||||
rehypeDocument,
|
||||
{
|
||||
title: `${title ? `${title} & ` : ''} ${subTitle} Quick Reference`,
|
||||
css: [...options.css],
|
||||
link: [
|
||||
{rel: 'icon', href: favicon, type: 'image/svg+xml'}
|
||||
],
|
||||
link: [{ rel: 'icon', href: favicon, type: 'image/svg+xml' }],
|
||||
meta: [
|
||||
{ description: `${description}为开发人员分享快速参考备忘单。` },
|
||||
{ keywords: `Quick,Reference,cheatsheet,${!options.isHome && options.filename || ''}` }
|
||||
]
|
||||
}],
|
||||
{ keywords: `Quick,Reference,cheatsheet,${(!options.isHome && options.filename) || ''}` },
|
||||
],
|
||||
},
|
||||
],
|
||||
],
|
||||
filterPlugins: (type, plugins = []) => {
|
||||
if (type === 'rehype') {
|
||||
const dt = plugins.filter((plug) => {
|
||||
return /(rehypeRaw)/.test(plug.name) ? false : true;
|
||||
});
|
||||
// 放在 rehypeDocument 前面
|
||||
dt.unshift(rehypeRaw);
|
||||
dt.unshift(rehypePreviewHTML);
|
||||
return dt;
|
||||
}
|
||||
return plugins;
|
||||
},
|
||||
rewrite: (node, index, parent) => {
|
||||
rehypeTitle(node, options.filename);
|
||||
homeCardIcons(node, parent, options.isHome);
|
||||
tooltips(node, index, parent);
|
||||
htmlTagAddAttri(node, options);
|
||||
rehypeUrls(node);
|
||||
if (node.children) {
|
||||
if (node.type === 'element' && node.tagName === 'body') {
|
||||
node.children = getTocsTree([ ...node.children ]);
|
||||
const tocsData = getTocsTree([...node.children]);
|
||||
if (!options.isHome) {
|
||||
const tocsMenus = getTocsTitleNode([...tocsData]);
|
||||
node.children = addTocsInWarp([...tocsData], getTocsTitleNodeWarpper(tocsMenus));
|
||||
} else {
|
||||
node.children = tocsData;
|
||||
}
|
||||
node.children.unshift(header(options));
|
||||
node.children.push(footer());
|
||||
node.children.push(anchorPoint());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
return markdown(str, mdOptions);
|
||||
}
|
@ -11,15 +11,20 @@ export const CSS_OUTPUT_PATH = path.resolve(OUTOUT, 'style/style.css');
|
||||
export async function createHTML(files = [], num = 0) {
|
||||
const dataFile = files[num];
|
||||
if (!dataFile) {
|
||||
console.log(' \n done!\n')
|
||||
console.log(' \n done!\n');
|
||||
return;
|
||||
}
|
||||
++num;
|
||||
const githubURL = `https://github.com/jaywcjlove/reference/blob/main/${path.relative(process.cwd(), dataFile.path).replace(path.sep, '/')}`;
|
||||
const githubURL = `https://github.com/jaywcjlove/reference/blob/main/${path
|
||||
.relative(process.cwd(), dataFile.path)
|
||||
.replace(path.sep, '/')}`;
|
||||
|
||||
const mdstr = await fs.readFile(dataFile.path);
|
||||
const htmlPath = path.relative(DOCS, dataFile.path);
|
||||
const outputHTMLPath = path.resolve(OUTOUT, 'docs', htmlPath).replace(/README.md$/i, 'index.html').replace(/.md$/, '.html');
|
||||
const outputHTMLPath = path
|
||||
.resolve(OUTOUT, 'docs', htmlPath)
|
||||
.replace(/README.md$/i, 'index.html')
|
||||
.replace(/.md$/, '.html');
|
||||
|
||||
await fs.ensureDir(path.dirname(outputHTMLPath));
|
||||
|
||||
@ -28,18 +33,18 @@ export async function createHTML(files = [], num = 0) {
|
||||
isHome: /README.md$/.test(path.relative(process.cwd(), dataFile.path)),
|
||||
githubURL,
|
||||
homePath: path.relative(path.dirname(outputHTMLPath), path.resolve(OUTOUT, 'index.html')),
|
||||
css: [path.relative(path.dirname(outputHTMLPath), CSS_OUTPUT_PATH)]
|
||||
css: [path.relative(path.dirname(outputHTMLPath), CSS_OUTPUT_PATH)],
|
||||
});
|
||||
await fs.writeFile(outputHTMLPath, html);
|
||||
console.log(`♻️ \x1b[32;1m ${path.relative(OUTOUT, outputHTMLPath)} \x1b[0m`)
|
||||
createHTML(files, num)
|
||||
console.log(`♻️ \x1b[32;1m ${path.relative(OUTOUT, outputHTMLPath)} \x1b[0m`);
|
||||
createHTML(files, num);
|
||||
}
|
||||
|
||||
export async function run() {
|
||||
await fs.ensureDir(OUTOUT);
|
||||
await fs.emptyDir(OUTOUT);
|
||||
await fs.ensureDir(path.dirname(CSS_OUTPUT_PATH));
|
||||
await fs.copyFile(CSSPATH, CSS_OUTPUT_PATH)
|
||||
await fs.copyFile(CSSPATH, CSS_OUTPUT_PATH);
|
||||
const files = await recursiveReaddirFiles(process.cwd(), {
|
||||
ignored: /\/(node_modules|\.git)/,
|
||||
exclude: /(\.json|\.mjs|CONTRIBUTING\.md)$/,
|
||||
|
@ -3,25 +3,25 @@ import { github, editor } from './logo.mjs';
|
||||
import { getSVGNode } from '../utils/getSVGNode.mjs';
|
||||
import { darkMode } from '../utils/darkMode.mjs';
|
||||
|
||||
const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets/quickreference.svg')
|
||||
const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets/quickreference.svg');
|
||||
export function header({ homePath, githubURL = '' }) {
|
||||
const svgNode = getSVGNode(ICONS_PATH)
|
||||
const svgNode = getSVGNode(ICONS_PATH);
|
||||
const data = [
|
||||
{
|
||||
menu: true,
|
||||
href: githubURL,
|
||||
target: '__blank',
|
||||
label: '编辑',
|
||||
children: [editor]
|
||||
children: [editor],
|
||||
},
|
||||
...darkMode(),
|
||||
{
|
||||
menu: true,
|
||||
href: 'https://github.com/jaywcjlove/reference',
|
||||
target: '__blank',
|
||||
children: [github]
|
||||
}
|
||||
]
|
||||
children: [github],
|
||||
},
|
||||
];
|
||||
return {
|
||||
type: 'element',
|
||||
tagName: 'nav',
|
||||
@ -51,10 +51,8 @@ export function header({ homePath, githubURL = '' }) {
|
||||
properties: {
|
||||
class: ['title'],
|
||||
},
|
||||
children: [
|
||||
{ type: 'text', value: 'Quick Reference' }
|
||||
]
|
||||
}
|
||||
children: [{ type: 'text', value: 'Quick Reference' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@ -75,29 +73,28 @@ export function header({ homePath, githubURL = '' }) {
|
||||
type: 'element',
|
||||
tagName: 'span',
|
||||
properties: {},
|
||||
children: label ? [
|
||||
{ type: 'text', value: label }
|
||||
] : []
|
||||
}
|
||||
]
|
||||
}
|
||||
children: label ? [{ type: 'text', value: label }] : [],
|
||||
},
|
||||
],
|
||||
};
|
||||
if (label) {
|
||||
childs.children = [...children, {
|
||||
childs.children = [
|
||||
...children,
|
||||
{
|
||||
type: 'element',
|
||||
tagName: 'span',
|
||||
properties: {},
|
||||
children: [
|
||||
{ type: 'text', value: label }
|
||||
]
|
||||
}];
|
||||
children: [{ type: 'text', value: label }],
|
||||
},
|
||||
];
|
||||
} else {
|
||||
childs.children = children;
|
||||
}
|
||||
return childs
|
||||
return childs;
|
||||
}),
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
@ -3,38 +3,38 @@ export const logo = [
|
||||
type: 'element',
|
||||
tagName: 'svg',
|
||||
properties: {
|
||||
viewBox: "0 0 24 24",
|
||||
fill: "none",
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
height: "1em",
|
||||
width: "1em"
|
||||
viewBox: '0 0 24 24',
|
||||
fill: 'none',
|
||||
xmlns: 'http://www.w3.org/2000/svg',
|
||||
height: '1em',
|
||||
width: '1em',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'element',
|
||||
tagName: 'path',
|
||||
properties: {
|
||||
opacity: ".5",
|
||||
d: "m21.66 10.44-.98 4.18c-.84 3.61-2.5 5.07-5.62 4.77-.5-.04-1.04-.13-1.62-.27l-1.68-.4c-4.17-.99-5.46-3.05-4.48-7.23l.98-4.19c.2-.85.44-1.59.74-2.2 1.17-2.42 3.16-3.07 6.5-2.28l1.67.39c4.19.98 5.47 3.05 4.49 7.23Z",
|
||||
fill: "white"
|
||||
opacity: '.5',
|
||||
d: 'm21.66 10.44-.98 4.18c-.84 3.61-2.5 5.07-5.62 4.77-.5-.04-1.04-.13-1.62-.27l-1.68-.4c-4.17-.99-5.46-3.05-4.48-7.23l.98-4.19c.2-.85.44-1.59.74-2.2 1.17-2.42 3.16-3.07 6.5-2.28l1.67.39c4.19.98 5.47 3.05 4.49 7.23Z',
|
||||
fill: 'white',
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'element',
|
||||
tagName: 'path',
|
||||
properties: {
|
||||
d: "M15.06 19.39c-.62.42-1.4.77-2.35 1.08l-1.58.52c-3.97 1.28-6.06.21-7.35-3.76L2.5 13.28c-1.28-3.97-.22-6.07 3.75-7.35l1.58-.52c.41-.13.8-.24 1.17-.31-.3.61-.54 1.35-.74 2.2l-.98 4.19c-.98 4.18.31 6.24 4.48 7.23l1.68.4c.58.14 1.12.23 1.62.27Zm2.43-8.88c-.06 0-.12-.01-.19-.02l-4.85-1.23a.75.75 0 0 1 .37-1.45l4.85 1.23a.748.748 0 0 1-.18 1.47Z" ,
|
||||
fill: "#cbd5e1"
|
||||
d: 'M15.06 19.39c-.62.42-1.4.77-2.35 1.08l-1.58.52c-3.97 1.28-6.06.21-7.35-3.76L2.5 13.28c-1.28-3.97-.22-6.07 3.75-7.35l1.58-.52c.41-.13.8-.24 1.17-.31-.3.61-.54 1.35-.74 2.2l-.98 4.19c-.98 4.18.31 6.24 4.48 7.23l1.68.4c.58.14 1.12.23 1.62.27Zm2.43-8.88c-.06 0-.12-.01-.19-.02l-4.85-1.23a.75.75 0 0 1 .37-1.45l4.85 1.23a.748.748 0 0 1-.18 1.47Z',
|
||||
fill: '#cbd5e1',
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'element',
|
||||
tagName: 'path',
|
||||
properties: {
|
||||
d: "M14.56 13.89c-.06 0-.12-.01-.19-.02l-2.91-.74a.75.75 0 0 1 .37-1.45l2.91.74c.4.1.64.51.54.91-.08.34-.38.56-.72.56Z",
|
||||
fill: "#292D32"
|
||||
d: 'M14.56 13.89c-.06 0-.12-.01-.19-.02l-2.91-.74a.75.75 0 0 1 .37-1.45l2.91.74c.4.1.64.51.54.91-.08.34-.38.56-.72.56Z',
|
||||
fill: '#292D32',
|
||||
},
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
@ -43,48 +43,45 @@ export const logo = [
|
||||
properties: {
|
||||
class: ['title'],
|
||||
},
|
||||
children: [
|
||||
{ type: 'text', value: 'Quick Reference' }
|
||||
]
|
||||
}
|
||||
children: [{ type: 'text', value: 'Quick Reference' }],
|
||||
},
|
||||
];
|
||||
|
||||
export const github = {
|
||||
type: 'element',
|
||||
tagName: 'svg',
|
||||
properties: {
|
||||
viewBox: "0 0 16 16",
|
||||
fill: "currentColor",
|
||||
height: "1em",
|
||||
width: "1em"
|
||||
viewBox: '0 0 16 16',
|
||||
fill: 'currentColor',
|
||||
height: '1em',
|
||||
width: '1em',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'element',
|
||||
tagName: 'path',
|
||||
properties: {
|
||||
d: "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z",
|
||||
d: 'M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z',
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export const editor = {
|
||||
type: 'element',
|
||||
tagName: 'svg',
|
||||
properties: {
|
||||
viewBox: "0 0 36 36",
|
||||
fill: "currentColor",
|
||||
height: "1em",
|
||||
width: "1em"
|
||||
viewBox: '0 0 36 36',
|
||||
fill: 'currentColor',
|
||||
height: '1em',
|
||||
width: '1em',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'element',
|
||||
tagName: 'path',
|
||||
properties: {
|
||||
d: "m33 6.4-3.7-3.7a1.71 1.71 0 0 0-2.36 0L23.65 6H6a2 2 0 0 0-2 2v22a2 2 0 0 0 2 2h22a2 2 0 0 0 2-2V11.76l3-3a1.67 1.67 0 0 0 0-2.36ZM18.83 20.13l-4.19.93 1-4.15 9.55-9.57 3.23 3.23ZM29.5 9.43 26.27 6.2l1.85-1.85 3.23 3.23Z",
|
||||
d: 'm33 6.4-3.7-3.7a1.71 1.71 0 0 0-2.36 0L23.65 6H6a2 2 0 0 0-2 2v22a2 2 0 0 0 2 2h22a2 2 0 0 0 2-2V11.76l3-3a1.67 1.67 0 0 0 0-2.36ZM18.83 20.13l-4.19.93 1-4.15 9.55-9.57 3.23 3.23ZM29.5 9.43 26.27 6.2l1.85-1.85 3.23 3.23Z',
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -92,8 +89,8 @@ export const editor = {
|
||||
tagName: 'path',
|
||||
properties: {
|
||||
fill: 'none',
|
||||
d: "M0 0h36v36H0z",
|
||||
d: 'M0 0h36v36H0z',
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
};
|
||||
|
@ -6,7 +6,8 @@ body {
|
||||
tab-size: 4;
|
||||
margin: 0;
|
||||
line-height: inherit;
|
||||
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji',
|
||||
'Segoe UI Emoji';
|
||||
}
|
||||
|
||||
[data-color-mode*='dark'] body .dark {
|
||||
@ -22,7 +23,8 @@ body {
|
||||
display: none;
|
||||
}
|
||||
|
||||
[data-color-mode*='light'], [data-color-mode*='light'] body {
|
||||
[data-color-mode*='light'],
|
||||
[data-color-mode*='light'] body {
|
||||
--color-prettylights-syntax-comment: #b1bac3;
|
||||
--color-prettylights-syntax-constant: #0550ae;
|
||||
--color-prettylights-syntax-entity: #8250df;
|
||||
@ -42,7 +44,7 @@ body {
|
||||
--color-prettylights-syntax-markup-italic: #24292f;
|
||||
--color-prettylights-syntax-markup-bold: #24292f;
|
||||
--color-prettylights-syntax-markup-deleted-text: #82071e;
|
||||
--color-prettylights-syntax-markup-deleted-bg: #FFEBE9;
|
||||
--color-prettylights-syntax-markup-deleted-bg: #ffebe9;
|
||||
--color-prettylights-syntax-markup-inserted-text: #116329;
|
||||
--color-prettylights-syntax-markup-inserted-bg: #dafbe1;
|
||||
--color-prettylights-syntax-markup-changed-text: #953800;
|
||||
@ -66,9 +68,11 @@ body {
|
||||
--color-accent-emphasis: #0969da;
|
||||
--color-attention-subtle: #fff8c5;
|
||||
--color-danger-fg: #cf222e;
|
||||
--box-shadow: 109 109 109;
|
||||
}
|
||||
|
||||
[data-color-mode*='dark'], [data-color-mode*='dark'] body {
|
||||
[data-color-mode*='dark'],
|
||||
[data-color-mode*='dark'] body {
|
||||
--color-prettylights-syntax-comment: #8b949e;
|
||||
--color-prettylights-syntax-constant: #79c0ff;
|
||||
--color-prettylights-syntax-entity: #d2a8ff;
|
||||
@ -112,6 +116,7 @@ body {
|
||||
--color-accent-emphasis: #1f6feb;
|
||||
--color-attention-subtle: rgba(187, 128, 9, 0.15);
|
||||
--color-danger-fg: #f85149;
|
||||
--box-shadow: 0 0 0;
|
||||
}
|
||||
|
||||
body {
|
||||
@ -119,18 +124,39 @@ body {
|
||||
background-color: var(--color-canvas-default);
|
||||
}
|
||||
|
||||
*, ::before, ::after {
|
||||
*,
|
||||
::before,
|
||||
::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
blockquote, dl, dd, h1, h2, h3, h4, h5, h6, hr, figure, p, pre {
|
||||
blockquote,
|
||||
dl,
|
||||
dd,
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6,
|
||||
hr,
|
||||
figure,
|
||||
p,
|
||||
pre {
|
||||
margin: 0;
|
||||
}
|
||||
h1,h2,h3,h4,h5,h6 {
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
font-size: inherit;
|
||||
font-weight: inherit
|
||||
font-weight: inherit;
|
||||
}
|
||||
ol, ul, menu {
|
||||
ol,
|
||||
ul,
|
||||
menu {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
@ -143,12 +169,16 @@ pur {
|
||||
color: var(--color-prettylights-syntax-entity);
|
||||
}
|
||||
|
||||
.wrap-body > p > code, .wrap-body > ul li > code, .wrap-body tbody td code {
|
||||
.wrap-body > p > code,
|
||||
.wrap-body > ul li > code,
|
||||
.wrap-body tbody td code {
|
||||
--text-opacity: 1;
|
||||
color: rgb(5 150 105 / var(--text-opacity));
|
||||
}
|
||||
|
||||
.wrap-body em, .wrap-body sup, .wrap-body sub {
|
||||
.wrap-body em,
|
||||
.wrap-body sup,
|
||||
.wrap-body sub {
|
||||
color: var(--color-fg-subtle);
|
||||
}
|
||||
|
||||
@ -156,13 +186,16 @@ table {
|
||||
width: 100%;
|
||||
text-indent: 0;
|
||||
border-color: inherit;
|
||||
border-collapse: collapse
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table td:first-child {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
table.shortcuts td:not(:last-child)>code, table.shortcuts td:not(:last-child)>del>code, ul.shortcuts li > code, kbd {
|
||||
table.shortcuts td:not(:last-child) > code,
|
||||
table.shortcuts td:not(:last-child) > del > code,
|
||||
ul.shortcuts li > code,
|
||||
kbd {
|
||||
background-color: var(--color-neutral-muted);
|
||||
color: var(--color-fg-subtle);
|
||||
box-shadow: 0 0 #0000, 0 0 #0000, 0 0 #0000;
|
||||
@ -181,11 +214,13 @@ table tr+tr {
|
||||
border-top: solid 1px #ececec94;
|
||||
border-color: var(--color-border-muted);
|
||||
}
|
||||
table td, table th {
|
||||
table td,
|
||||
table th {
|
||||
padding: 9px 14px;
|
||||
text-align: left;
|
||||
}
|
||||
table tr th:last-child, table tr td:last-child {
|
||||
table tr th:last-child,
|
||||
table tr td:last-child {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
@ -203,7 +238,9 @@ table td:first-child>code {
|
||||
--text-opacity: 1;
|
||||
color: rgb(5 150 105 / var(--text-opacity));
|
||||
}
|
||||
table td > del, table td:first-child > del > code, .wrap-body p > del > code {
|
||||
table td > del,
|
||||
table td:first-child > del > code,
|
||||
.wrap-body p > del > code {
|
||||
color: var(--color-danger-fg);
|
||||
}
|
||||
|
||||
@ -211,16 +248,19 @@ table.show-header thead {
|
||||
display: table-header-group;
|
||||
}
|
||||
|
||||
table.style-list td + td, table.style-list-arrow td + td {
|
||||
table.style-list td + td,
|
||||
table.style-list-arrow td + td {
|
||||
padding-top: 0 !important;
|
||||
}
|
||||
|
||||
table.style-list td, table.style-list-arrow td {
|
||||
table.style-list td,
|
||||
table.style-list-arrow td {
|
||||
display: block;
|
||||
text-align: left !important;
|
||||
}
|
||||
|
||||
table.style-list-arrow td:first-child::before, ul.style-arrow li:before {
|
||||
table.style-list-arrow td:first-child::before,
|
||||
ul.style-arrow li:before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
width: 0px;
|
||||
@ -231,7 +271,8 @@ table.style-list-arrow td:first-child::before, ul.style-arrow li:before {
|
||||
border-bottom: 5px solid transparent;
|
||||
}
|
||||
|
||||
tt, code {
|
||||
tt,
|
||||
code {
|
||||
font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
|
||||
font-size: 1em;
|
||||
}
|
||||
@ -252,7 +293,8 @@ pre {
|
||||
.max-container a {
|
||||
color: rgb(2 132 199/1);
|
||||
}
|
||||
.max-container a, .max-container a:visited {
|
||||
.max-container a,
|
||||
.max-container a:visited {
|
||||
background-image: linear-gradient(transparent, transparent 6px, #34495e 6px, #34495e);
|
||||
background-position: bottom;
|
||||
background-size: 100% 6px;
|
||||
@ -263,7 +305,8 @@ pre {
|
||||
text-decoration-color: transparent;
|
||||
}
|
||||
|
||||
.max-container a:hover, .max-container a:visited:hover{
|
||||
.max-container a:hover,
|
||||
.max-container a:visited:hover {
|
||||
text-decoration-color: #10b981;
|
||||
}
|
||||
|
||||
@ -274,7 +317,8 @@ pre {
|
||||
padding: 0.75rem;
|
||||
}
|
||||
|
||||
body.home .h1wrap-body, body.home .h1wrap .wrap-body {
|
||||
body.home .h1wrap-body,
|
||||
body.home .h1wrap .wrap-body {
|
||||
max-width: 940px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
@ -309,8 +353,9 @@ body:not(.home) .h2wrap > .wrap-body > ul {
|
||||
body.home .h1wrap p {
|
||||
text-align: left;
|
||||
}
|
||||
body.home .max-container a.home-button:hover, body.home .max-container a.home-button:visited:hover {
|
||||
transition: all .3s;
|
||||
body.home .max-container a.home-button:hover,
|
||||
body.home .max-container a.home-button:visited:hover {
|
||||
transition: all 0.3s;
|
||||
text-decoration-color: #fff;
|
||||
color: #fff;
|
||||
}
|
||||
@ -343,7 +388,7 @@ body.home .max-container a.home-button:hover, body.home .max-container a.home-bu
|
||||
color: rgb(241 245 249 / var(--text-opacity));
|
||||
--bg-opacity: 0.5;
|
||||
background-color: rgb(62 69 72 / var(--bg-opacity));
|
||||
transition: all .3s;
|
||||
transition: all 0.3s;
|
||||
text-decoration: none;
|
||||
}
|
||||
.home-card a:hover {
|
||||
@ -388,7 +433,10 @@ a.text-grey {
|
||||
padding: 1.8rem 1.8rem 0;
|
||||
}
|
||||
|
||||
.header-nav .max-container, .header-nav .logo, .header-nav .menu, .header-nav .menu a {
|
||||
.header-nav .max-container,
|
||||
.header-nav .logo,
|
||||
.header-nav .menu,
|
||||
.header-nav .menu a {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
@ -409,17 +457,19 @@ a.text-grey {
|
||||
font-size: 40px;
|
||||
}
|
||||
|
||||
.header-nav .menu a:hover, .header-nav .menu button:hover {
|
||||
.header-nav .menu a:hover,
|
||||
.header-nav .menu button:hover {
|
||||
background-color: var(--color-neutral-muted);
|
||||
}
|
||||
|
||||
.header-nav .menu a, .header-nav .menu button {
|
||||
.header-nav .menu a,
|
||||
.header-nav .menu button {
|
||||
padding-left: 0.75rem;
|
||||
padding-right: 0.75rem;
|
||||
padding-top: 0.5rem;
|
||||
padding-bottom: 0.5rem;
|
||||
border-radius: 9999px;
|
||||
transition: all .3s;
|
||||
transition: all 0.3s;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
@ -441,7 +491,8 @@ a.text-grey {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.header-nav a, .header-nav a:visited {
|
||||
.header-nav a,
|
||||
.header-nav a:visited {
|
||||
color: var(--color-fg-default);
|
||||
line-height: 1.2;
|
||||
gap: 0.3rem;
|
||||
@ -474,6 +525,66 @@ a.text-grey {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3rem;
|
||||
position: relative;
|
||||
}
|
||||
.menu-tocs {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 88;
|
||||
display: inline-flex;
|
||||
}
|
||||
.menu-tocs:hover > .menu-modal {
|
||||
display: block;
|
||||
border-radius: 0.5rem;
|
||||
padding: 0.3rem;
|
||||
max-height: 100vh;
|
||||
overflow: auto;
|
||||
background-color: var(--color-canvas-subtle);
|
||||
box-shadow: 0 8px 24px rgba(var(--box-shadow) / 0.2);
|
||||
}
|
||||
.menu-tocs > .menu-btn {
|
||||
border: 1px solid var(--color-border-default);
|
||||
display: flex;
|
||||
border-radius: 0.3rem;
|
||||
padding: 0.3rem 0.4rem;
|
||||
font-size: 1.3rem;
|
||||
margin-left: -3rem;
|
||||
margin-top: 0.3rem;
|
||||
position: absolute;
|
||||
}
|
||||
.menu-tocs > .menu-modal {
|
||||
width: 260px;
|
||||
position: absolute;
|
||||
display: none;
|
||||
margin-left: -1rem;
|
||||
}
|
||||
.menu-tocs > .menu-modal a + a {
|
||||
margin-bottom: 0.2rem;
|
||||
}
|
||||
.menu-tocs > .menu-modal a:hover {
|
||||
background-color: var(--color-neutral-muted);
|
||||
}
|
||||
.menu-tocs > .menu-modal a.is-active-link {
|
||||
background-color: var(--color-border-muted);
|
||||
text-decoration-color: #10b981;
|
||||
}
|
||||
.menu-tocs > .menu-modal a {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
padding: 0.3rem 0.5rem;
|
||||
}
|
||||
|
||||
.menu-tocs > .menu-modal a.leve2 {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.menu-tocs > .menu-modal a.leve3 {
|
||||
padding-left: 1.2rem;
|
||||
}
|
||||
.menu-tocs > .menu-modal a.leve4,
|
||||
.menu-tocs > .menu-modal a.leve5,
|
||||
.menu-tocs > .menu-modal a.leve6 {
|
||||
padding-left: 2.1rem;
|
||||
}
|
||||
|
||||
.wrap-header.h2wrap > h2 {
|
||||
@ -484,7 +595,8 @@ a.text-grey {
|
||||
font-size: 30px;
|
||||
line-height: 1.2;
|
||||
font-weight: 200;
|
||||
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
|
||||
'Droid Sans', 'Helvetica Neue', sans-serif;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
@ -495,7 +607,8 @@ a.text-grey {
|
||||
color: rgb(148 163 184/1);
|
||||
}
|
||||
|
||||
body:not(.home) .h2wrap > h2 a::after, body:not(.home) .h3wrap > h3 a::after {
|
||||
body:not(.home) .h2wrap > h2 a::after,
|
||||
body:not(.home) .h3wrap > h3 a::after {
|
||||
content: '#';
|
||||
padding-right: 0.5rem;
|
||||
color: rgb(16 185 129/1);
|
||||
@ -535,7 +648,8 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
.wrap-header.h3wrap > .wrap-body p, .wrap-header.h4wrap > .wrap-body p {
|
||||
.wrap-header.h3wrap > .wrap-body p,
|
||||
.wrap-header.h4wrap > .wrap-body p {
|
||||
margin: 0px;
|
||||
width: 100%;
|
||||
padding-left: 1rem;
|
||||
@ -550,7 +664,7 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
background-color: var(--color-bg-subtle);
|
||||
color: rgb(30 41 59/0);
|
||||
content: '-';
|
||||
line-height: 1.50rem;
|
||||
line-height: 1.5rem;
|
||||
top: 0;
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
@ -588,7 +702,6 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
.h4wrap > .wrap-body ul,
|
||||
.h4wrap > .wrap-body ol,
|
||||
.h4wrap > .wrap-body dl,
|
||||
|
||||
.h3wrap > .wrap-body ul,
|
||||
.h3wrap > .wrap-body ol,
|
||||
.h3wrap > .wrap-body dl {
|
||||
@ -654,7 +767,7 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
width: 1.5rem;
|
||||
text-align: center;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.30rem;
|
||||
line-height: 1.3rem;
|
||||
border: 2px solid #228e6c;
|
||||
top: -1px;
|
||||
left: -14px;
|
||||
@ -703,7 +816,8 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.h3wrap hr, .h3wrap-body hr {
|
||||
.h3wrap hr,
|
||||
.h3wrap-body hr {
|
||||
border-width: 0;
|
||||
border-style: solid;
|
||||
border-color: #e5e7eb;
|
||||
@ -741,33 +855,87 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.cols-1 { grid-template-columns: repeat(1,minmax(0,1fr)) !important; }
|
||||
.cols-2 { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
|
||||
.cols-3 { grid-template-columns: repeat(3,minmax(0,1fr)) !important; }
|
||||
.cols-4 { grid-template-columns: repeat(4,minmax(0,1fr)) !important; }
|
||||
.cols-5 { grid-template-columns: repeat(5,minmax(0,1fr)) !important; }
|
||||
.cols-6 { grid-template-columns: repeat(6,minmax(0,1fr)) !important; }
|
||||
.cols-7 { grid-template-columns: repeat(7,minmax(0,1fr)) !important; }
|
||||
.cols-8 { grid-template-columns: repeat(8,minmax(0,1fr)) !important; }
|
||||
.cols-9 { grid-template-columns: repeat(9,minmax(0,1fr)) !important; }
|
||||
.col-span-2 { grid-column: span 2/span 2; }
|
||||
.col-span-3 { grid-column: span 3/span 3; }
|
||||
.col-span-4 { grid-column: span 4/span 4; }
|
||||
.col-span-5 { grid-column: span 5/span 5; }
|
||||
.col-span-6 { grid-column: span 6/span 6; }
|
||||
.col-span-7 { grid-column: span 7/span 7; }
|
||||
.col-span-8 { grid-column: span 8/span 8; }
|
||||
.col-span-9 { grid-column: span 9/span 9; }
|
||||
.col-span-10 { grid-column: span 10/span 10; }
|
||||
.row-span-2 { grid-row: span 2/span 2; }
|
||||
.row-span-3 { grid-row: span 3/span 3; }
|
||||
.row-span-4 { grid-row: span 4/span 4; }
|
||||
.row-span-5 { grid-row: span 5/span 5; }
|
||||
.row-span-6 { grid-row: span 6/span 6; }
|
||||
.row-span-7 { grid-row: span 7/span 7; }
|
||||
.row-span-8 { grid-row: span 8/span 8; }
|
||||
.row-span-9 { grid-row: span 9/span 9; }
|
||||
.row-span-10 { grid-row: span 10/span 10; }
|
||||
.cols-1 {
|
||||
grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
|
||||
}
|
||||
.cols-2 {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
|
||||
}
|
||||
.cols-3 {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
|
||||
}
|
||||
.cols-4 {
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
|
||||
}
|
||||
.cols-5 {
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
|
||||
}
|
||||
.cols-6 {
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
|
||||
}
|
||||
.cols-7 {
|
||||
grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
|
||||
}
|
||||
.cols-8 {
|
||||
grid-template-columns: repeat(8, minmax(0, 1fr)) !important;
|
||||
}
|
||||
.cols-9 {
|
||||
grid-template-columns: repeat(9, minmax(0, 1fr)) !important;
|
||||
}
|
||||
.col-span-2 {
|
||||
grid-column: span 2 / span 2;
|
||||
}
|
||||
.col-span-3 {
|
||||
grid-column: span 3 / span 3;
|
||||
}
|
||||
.col-span-4 {
|
||||
grid-column: span 4 / span 4;
|
||||
}
|
||||
.col-span-5 {
|
||||
grid-column: span 5 / span 5;
|
||||
}
|
||||
.col-span-6 {
|
||||
grid-column: span 6 / span 6;
|
||||
}
|
||||
.col-span-7 {
|
||||
grid-column: span 7 / span 7;
|
||||
}
|
||||
.col-span-8 {
|
||||
grid-column: span 8 / span 8;
|
||||
}
|
||||
.col-span-9 {
|
||||
grid-column: span 9 / span 9;
|
||||
}
|
||||
.col-span-10 {
|
||||
grid-column: span 10 / span 10;
|
||||
}
|
||||
.row-span-2 {
|
||||
grid-row: span 2 / span 2;
|
||||
}
|
||||
.row-span-3 {
|
||||
grid-row: span 3 / span 3;
|
||||
}
|
||||
.row-span-4 {
|
||||
grid-row: span 4 / span 4;
|
||||
}
|
||||
.row-span-5 {
|
||||
grid-row: span 5 / span 5;
|
||||
}
|
||||
.row-span-6 {
|
||||
grid-row: span 6 / span 6;
|
||||
}
|
||||
.row-span-7 {
|
||||
grid-row: span 7 / span 7;
|
||||
}
|
||||
.row-span-8 {
|
||||
grid-row: span 8 / span 8;
|
||||
}
|
||||
.row-span-9 {
|
||||
grid-row: span 9 / span 9;
|
||||
}
|
||||
.row-span-10 {
|
||||
grid-row: span 10 / span 10;
|
||||
}
|
||||
|
||||
.wrap-text {
|
||||
white-space: pre-wrap !important;
|
||||
@ -790,7 +958,7 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
opacity: 0;
|
||||
border-radius: 0.5rem;
|
||||
z-index: 1;
|
||||
transition: opacity .6s;
|
||||
transition: opacity 0.6s;
|
||||
line-height: 1.5;
|
||||
|
||||
width: 220px;
|
||||
@ -799,7 +967,7 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
margin-left: -110px;
|
||||
}
|
||||
.tooltip .tooltiptext::after {
|
||||
content: "";
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 50%;
|
||||
@ -815,17 +983,34 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
}
|
||||
|
||||
/* 代码高亮 Start */
|
||||
.token.comment, .token.prolog, .token.doctype, .token.cdata {
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: var(--color-prettylights-syntax-comment);
|
||||
}
|
||||
.token.namespace { opacity: 0.7; }
|
||||
.token.tag, .token.selector, .token.constant, .token.symbol, .token.deleted {
|
||||
.token.namespace {
|
||||
opacity: 0.7;
|
||||
}
|
||||
.token.tag,
|
||||
.token.selector,
|
||||
.token.constant,
|
||||
.token.symbol,
|
||||
.token.deleted {
|
||||
color: var(--color-prettylights-syntax-entity-tag);
|
||||
}
|
||||
.token.maybe-class-name {
|
||||
color: var(--color-prettylights-syntax-entity);
|
||||
}
|
||||
.token.property-access, .token.operator, .token.boolean, .token.number, .token.selector .token.class, .token.attr-name, .token.string, .token.char, .token.builtin {
|
||||
.token.property-access,
|
||||
.token.operator,
|
||||
.token.boolean,
|
||||
.token.number,
|
||||
.token.selector .token.class,
|
||||
.token.attr-name,
|
||||
.token.string,
|
||||
.token.char,
|
||||
.token.builtin {
|
||||
color: var(--color-prettylights-syntax-constant);
|
||||
}
|
||||
.token.deleted {
|
||||
@ -850,13 +1035,23 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
.token.variable {
|
||||
color: var(--color-prettylights-syntax-constant);
|
||||
}
|
||||
.token.entity, .token.url, .language-css .token.string, .style .token.string {
|
||||
.token.entity,
|
||||
.token.url,
|
||||
.language-css .token.string,
|
||||
.style .token.string {
|
||||
color: var(--color-prettylights-syntax-string);
|
||||
}
|
||||
.token.color, .token.atrule, .token.attr-value, .token.function, .token.class-name {
|
||||
.token.color,
|
||||
.token.atrule,
|
||||
.token.attr-value,
|
||||
.token.function,
|
||||
.token.class-name {
|
||||
color: var(--color-prettylights-syntax-string);
|
||||
}
|
||||
.token.rule, .token.regex, .token.important, .token.keyword {
|
||||
.token.rule,
|
||||
.token.regex,
|
||||
.token.important,
|
||||
.token.keyword {
|
||||
color: var(--color-prettylights-syntax-keyword);
|
||||
}
|
||||
.token.module {
|
||||
@ -881,9 +1076,16 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
color: var(--color-prettylights-syntax-variable);
|
||||
}
|
||||
|
||||
.token.important, .token.bold { font-weight: bold; }
|
||||
.token.italic { font-style: italic; }
|
||||
.token.entity { cursor: help; }
|
||||
.token.important,
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.highlight-line {
|
||||
background-color: var(--color-neutral-muted);
|
||||
@ -923,7 +1125,8 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
.header-nav .max-container {
|
||||
padding-top: 0.85rem;
|
||||
}
|
||||
.header-nav .menu a, .header-nav .menu button {
|
||||
.header-nav .menu a,
|
||||
.header-nav .menu button {
|
||||
padding: 0.2rem 0.3rem;
|
||||
}
|
||||
.wrap-header.h1wrap > h1 {
|
||||
@ -959,23 +1162,25 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
.footer-wrap {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
table {
|
||||
table.auto-wrap {
|
||||
overflow: auto;
|
||||
display: block;
|
||||
}
|
||||
table td, table th {
|
||||
table.auto-wrap thead {
|
||||
display: none;
|
||||
}
|
||||
table.auto-wrap td,
|
||||
table.auto-wrap th {
|
||||
display: block;
|
||||
text-align: left !important;
|
||||
}
|
||||
table td + td, table th + th {
|
||||
table td + td,
|
||||
table th + th {
|
||||
padding-top: 0 !important;
|
||||
}
|
||||
table td:first-child {
|
||||
white-space: initial;
|
||||
}
|
||||
.wrap-header.h3wrap > .wrap-body {
|
||||
overflow: initial;
|
||||
}
|
||||
.tooltip:hover .tooltiptext {
|
||||
display: inline-block;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
const scripts = `
|
||||
if(('onhashchange' in window) && ((typeof document.documentMode==='undefined') || document.documentMode==8)) {
|
||||
window.onhashchange = function () {
|
||||
anchorPoint()
|
||||
updateAnchor()
|
||||
};
|
||||
}
|
||||
function anchorPoint() {
|
||||
@ -16,15 +16,37 @@ function anchorPoint() {
|
||||
}
|
||||
}
|
||||
anchorPoint();
|
||||
|
||||
function updateAnchor(element) {
|
||||
const anchorContainer = document.querySelectorAll('.menu-tocs .menu-modal a.tocs-link');
|
||||
anchorContainer.forEach((tocanchor) => {
|
||||
tocanchor.classList.remove('is-active-link');
|
||||
});
|
||||
const anchor = element || document.querySelector(\`a.tocs-link[href='\${decodeURIComponent(window.location.hash)}']\`);
|
||||
console.log('anchor', anchor)
|
||||
if (anchor) {
|
||||
anchor.classList.add('is-active-link');
|
||||
}
|
||||
}
|
||||
// toc 定位
|
||||
updateAnchor()
|
||||
const anchor = document.querySelectorAll('.menu-tocs .menu-modal a.tocs-link');
|
||||
anchor.forEach((item) => {
|
||||
item.addEventListener('click', (e) => {
|
||||
updateAnchor()
|
||||
})
|
||||
})
|
||||
`;
|
||||
|
||||
export function anchorPoint() {
|
||||
return {
|
||||
type: 'element',
|
||||
tagName: 'script',
|
||||
children: [{
|
||||
children: [
|
||||
{
|
||||
type: 'text',
|
||||
value: scripts,
|
||||
}]
|
||||
}
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
|
||||
export function getChilds(data = [], level, result = []) {
|
||||
for (let i = 1; i <= data.length; i++) {
|
||||
const titleNum = Number(data[i]?.tagName?.replace(/^h/, ''));
|
||||
|
@ -21,27 +21,27 @@ const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets');
|
||||
export function darkMode() {
|
||||
const iconSunPath = path.resolve(ICONS_PATH, `sun.svg`);
|
||||
const iconMoonPath = path.resolve(ICONS_PATH, `moon.svg`);
|
||||
const sunNode = getSVGNode(iconSunPath)
|
||||
const moonNode = getSVGNode(iconMoonPath)
|
||||
const sunNode = getSVGNode(iconSunPath);
|
||||
const moonNode = getSVGNode(iconMoonPath);
|
||||
return [
|
||||
{
|
||||
type: 'element',
|
||||
tagName: 'button',
|
||||
properties: {
|
||||
id: 'darkMode',
|
||||
type: 'button'
|
||||
type: 'button',
|
||||
},
|
||||
children: [
|
||||
...sunNode,
|
||||
...moonNode
|
||||
]
|
||||
}, {
|
||||
children: [...sunNode, ...moonNode],
|
||||
},
|
||||
{
|
||||
type: 'element',
|
||||
tagName: 'script',
|
||||
children: [{
|
||||
children: [
|
||||
{
|
||||
type: 'text',
|
||||
value: scripts,
|
||||
}]
|
||||
}
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
@ -1,13 +1,24 @@
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import rehypeParse from 'rehype-parse';
|
||||
import { unified } from 'unified';
|
||||
import { VFile } from 'vfile';
|
||||
|
||||
export function getSVGNode(iconPath) {
|
||||
export const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets');
|
||||
|
||||
export function getSVGNode(iconPath, space = 'svg') {
|
||||
const svgStr = fs.readFileSync(iconPath);
|
||||
const processor = unified().use(rehypeParse,{ fragment: true, space: "svg" })
|
||||
const processor = unified().use(rehypeParse, { fragment: true, space });
|
||||
const file = new VFile();
|
||||
file.value = svgStr.toString();
|
||||
const hastNode = processor.runSync(processor.parse(file), file);
|
||||
return hastNode.children || []
|
||||
return hastNode.children || [];
|
||||
}
|
||||
|
||||
export function getVNode(str = '', space = 'html') {
|
||||
const processor = unified().use(rehypeParse, { fragment: true, space });
|
||||
const file = new VFile();
|
||||
file.value = str.toString();
|
||||
const hastNode = processor.runSync(processor.parse(file), file);
|
||||
return hastNode.children || [];
|
||||
}
|
@ -1,5 +1,70 @@
|
||||
import path from 'path';
|
||||
import { getCodeString } from 'rehype-rewrite';
|
||||
import { panelAddNumber } from './panelAddNumber.mjs';
|
||||
import { getChilds, getHeader } from './childs.mjs';
|
||||
import { ICONS_PATH, getSVGNode } from './getSVGNode.mjs';
|
||||
|
||||
export const titleNum = (tagName = '') => Number(tagName.replace(/^h/, ''));
|
||||
|
||||
export function getTocsTitleNode(arr = [], result = []) {
|
||||
arr.forEach(({ tagName, type, properties, children }) => {
|
||||
if (/^h[23456]/.test(tagName)) {
|
||||
const num = titleNum(tagName);
|
||||
const props = { 'aria-hidden': 'true', class: `leve${num} tocs-link`, href: '#' + (properties.id || '') };
|
||||
const title = getCodeString(children || []);
|
||||
result.push({ tagName: 'a', type, properties: props, children: [{ type: 'text', value: title || ' ' }] });
|
||||
} else if (children?.length > 0) {
|
||||
result = result.concat(getTocsTitleNode(children));
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
export function addTocsInWarp(tocsData = [], menuData, isDone = false) {
|
||||
const childs = tocsData.map((item) => {
|
||||
if (item.properties?.class?.includes('h1wrap-body')) {
|
||||
isDone = true;
|
||||
}
|
||||
if (!isDone && item.children) {
|
||||
item.children = addTocsInWarp([...item.children], menuData, isDone);
|
||||
}
|
||||
return item;
|
||||
});
|
||||
if (isDone) {
|
||||
childs.splice(1, 0, menuData);
|
||||
}
|
||||
return childs;
|
||||
}
|
||||
|
||||
export const getTocsTitleNodeWarpper = (children = []) => {
|
||||
const iconPath = path.resolve(ICONS_PATH, `menu.svg`);
|
||||
const svgNode = getSVGNode(iconPath);
|
||||
return {
|
||||
type: 'element',
|
||||
tagName: 'div',
|
||||
properties: {
|
||||
class: 'menu-tocs',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: 'element',
|
||||
tagName: 'div',
|
||||
properties: {
|
||||
class: 'menu-btn',
|
||||
},
|
||||
children: [...svgNode],
|
||||
},
|
||||
{
|
||||
type: 'element',
|
||||
tagName: 'div',
|
||||
properties: {
|
||||
class: 'menu-modal',
|
||||
},
|
||||
children: children,
|
||||
},
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
/** Markdown 文档转成树形结构 */
|
||||
export function getTocsTree(arr = [], result = []) {
|
||||
@ -14,16 +79,14 @@ export function getTocsTree(arr = [], result = []) {
|
||||
if (level === -1) {
|
||||
level = toc.number;
|
||||
}
|
||||
const titleNum = Number(toc.tagName?.replace(/^h/, ''));
|
||||
|
||||
if (toc.number === level && titleNum === level) {
|
||||
if (toc.number === level && titleNum(toc.tagName) === level) {
|
||||
const header = getHeader(data.slice(n), level);
|
||||
const wrapCls = ['wrap'];
|
||||
const headerCls = ['wrap-header', `h${level}wrap`];
|
||||
|
||||
if (level === 1) wrapCls.push('max-container');
|
||||
const wrapStyle = toc.properties['wrap-style'];
|
||||
delete toc.properties['wrap-style']
|
||||
delete toc.properties['wrap-style'];
|
||||
const wrapClass = toc.properties['wrap-class'];
|
||||
if (wrapClass) wrapCls.push(wrapClass);
|
||||
delete toc.properties['wrap-class'];
|
||||
@ -42,26 +105,24 @@ export function getTocsTree(arr = [], result = []) {
|
||||
type: 'element',
|
||||
tagName: 'div',
|
||||
properties: { class: 'wrap-body' },
|
||||
children: [
|
||||
...header
|
||||
children: [...header],
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
}
|
||||
};
|
||||
const childs = getChilds([...data.slice(n + 1)], level);
|
||||
const resultChilds = getTocsTree(childs);
|
||||
if (resultChilds.length > 0) {
|
||||
const bodyStyle = toc.properties['body-style'];
|
||||
delete toc.properties['body-style']
|
||||
delete toc.properties['body-style'];
|
||||
const bodyClass = toc.properties['body-class'];
|
||||
delete toc.properties['body-class']
|
||||
delete toc.properties['body-class'];
|
||||
panle.children = panle.children.concat({
|
||||
type: 'element',
|
||||
tagName: 'div',
|
||||
properties: { class: [`h${level}wrap-body`, bodyClass], style: bodyStyle },
|
||||
children: [...resultChilds]
|
||||
children: [...resultChilds],
|
||||
});
|
||||
}
|
||||
result.push(panle);
|
||||
|
@ -1,8 +1,6 @@
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import { getSVGNode } from './getSVGNode.mjs';
|
||||
|
||||
export const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets')
|
||||
import { getSVGNode, ICONS_PATH } from './getSVGNode.mjs';
|
||||
|
||||
export function homeCardIcons(node, parent, isHome) {
|
||||
if (isHome && node && node.type === 'element' && node.properties?.class?.includes('home-card')) {
|
||||
@ -17,7 +15,7 @@ export function homeCardIcons(node, parent, isHome) {
|
||||
type: 'element',
|
||||
tagName: 'span',
|
||||
children: child.children,
|
||||
}
|
||||
};
|
||||
if (iconExist) {
|
||||
const svgNode = getSVGNode(iconPath);
|
||||
child.children = [...svgNode, labelNode];
|
||||
@ -26,7 +24,7 @@ export function homeCardIcons(node, parent, isHome) {
|
||||
child.children = [...svgNode, labelNode];
|
||||
}
|
||||
}
|
||||
return child
|
||||
})
|
||||
return child;
|
||||
});
|
||||
}
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
|
||||
/** 标记 Number */
|
||||
export function panelAddNumber(arr = [], result = []) {
|
||||
let n = 0;
|
||||
@ -10,9 +9,9 @@ export function panelAddNumber(arr = [], result = []) {
|
||||
level = titleNum;
|
||||
}
|
||||
if (toc) {
|
||||
result.push({ ...toc, number: level })
|
||||
result.push({ ...toc, number: level });
|
||||
}
|
||||
n++;
|
||||
}
|
||||
return result
|
||||
return result;
|
||||
}
|
22
scripts/utils/rehypePreviewHTML.mjs
Normal file
22
scripts/utils/rehypePreviewHTML.mjs
Normal file
@ -0,0 +1,22 @@
|
||||
import { visit } from 'unist-util-visit';
|
||||
import { getCodeString } from 'rehype-rewrite';
|
||||
import { getVNode } from './getSVGNode.mjs';
|
||||
|
||||
export function rehypePreviewHTML() {
|
||||
return (tree) => {
|
||||
visit(tree, (node, index, parent) => {
|
||||
if (node.type === 'element' && node.tagName === 'pre') {
|
||||
const child = node.children[0];
|
||||
if (
|
||||
child.properties?.className?.includes('language-html') &&
|
||||
child?.tagName === 'code' &&
|
||||
child.data?.meta === 'preview'
|
||||
) {
|
||||
const code = getCodeString(child.children);
|
||||
const vnode = getVNode(code || '');
|
||||
node.children = vnode;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import { getSVGNode } from './getSVGNode.mjs';
|
||||
import { ICONS_PATH } from './homeCardIcons.mjs';
|
||||
import { getSVGNode, ICONS_PATH } from './getSVGNode.mjs';
|
||||
|
||||
export function rehypeTitle(node, iconName) {
|
||||
if (node.type === 'element' && node.tagName === 'h1' && iconName !== 'index') {
|
||||
|
@ -1,5 +1,10 @@
|
||||
export function rehypeUrls(node) {
|
||||
if (node.type === 'element' && node.properties?.href && /.md/.test(node.properties.href) && !/^(https?:\/\/)/.test(node.properties.href)) {
|
||||
if (
|
||||
node.type === 'element' &&
|
||||
node.properties?.href &&
|
||||
/.md/.test(node.properties.href) &&
|
||||
!/^(https?:\/\/)/.test(node.properties.href)
|
||||
) {
|
||||
let href = node.properties.href;
|
||||
node.properties.href = href.replace(/([^\.\/\\]+)\.(md|markdown)/gi, '$1.html');
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ export function tooltips(node, index, parent) {
|
||||
// 记录 tooltip 的开始位置
|
||||
if (node?.type === 'comment' && node?.value === 'rehype:tooltips') {
|
||||
recordPos = true;
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
// 记录 tooltip 的 node
|
||||
if (recordPos && !tooltipNode) {
|
||||
@ -33,24 +33,24 @@ export function tooltips(node, index, parent) {
|
||||
tooltipNode = node;
|
||||
tooltipNode.properties['class'] = 'tooltiptext';
|
||||
delete tooltipNode.position;
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// 将 tooltip 节点,插入到下一个 element 节点的子节点中
|
||||
if (tooltipNode) {
|
||||
if (node.type === 'comment' || (node.type === 'text' && !node?.value?.replace(/\s\n/g, ''))) {
|
||||
recordPos = false;
|
||||
tooltipNode = null
|
||||
tooltipNode = null;
|
||||
}
|
||||
if (tooltipNode && node?.type === 'element') {
|
||||
recordPos = false;
|
||||
node.properties['class'] = 'tooltip';
|
||||
node.children.push(tooltipNode);
|
||||
tooltipNode = null
|
||||
tooltipNode = null;
|
||||
}
|
||||
}
|
||||
if (!recordPos && node) {
|
||||
result.push(node)
|
||||
result.push(node);
|
||||
}
|
||||
}
|
||||
if (parent) {
|
||||
@ -59,6 +59,4 @@ export function tooltips(node, index, parent) {
|
||||
}
|
||||
}
|
||||
|
||||
export function getPreviewNode() {
|
||||
|
||||
}
|
||||
export function getPreviewNode() {}
|
||||
|
@ -3,17 +3,18 @@ import chokidar from 'chokidar';
|
||||
import { getStat } from 'recursive-readdir-files';
|
||||
import { run, DOCS, createHTML } from './index.mjs';
|
||||
|
||||
;(async () => {
|
||||
(async () => {
|
||||
await run();
|
||||
const homeMdPath = path.relative(process.cwd(), 'README.md')
|
||||
const homeMdPath = path.relative(process.cwd(), 'README.md');
|
||||
const watcher = chokidar.watch([DOCS, homeMdPath], {
|
||||
ignored: /(^|[\/\\])\../, // ignore dotfiles
|
||||
persistent: true
|
||||
persistent: true,
|
||||
});
|
||||
|
||||
watcher.on('change', async (path) => {
|
||||
const stats = await getStat(path)
|
||||
watcher
|
||||
.on('change', async (path) => {
|
||||
const stats = await getStat(path);
|
||||
createHTML([stats]);
|
||||
})
|
||||
.on('error', error => console.log(`Watcher error: ${error}`))
|
||||
.on('error', (error) => console.log(`Watcher error: ${error}`));
|
||||
})();
|
Reference in New Issue
Block a user