mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-16 20:21:22 +08:00
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
b37c268882 | |||
7edba8e207 | |||
efbd007801 | |||
f01c001040 | |||
727d47725f | |||
4e764197c7 | |||
64400ea686 | |||
a540fb7fd9 | |||
71d2bfce9a | |||
5685eb285a | |||
227a7a7149 | |||
a7c1d81698 | |||
e876e96430 | |||
cb5f742608 |
19
README.md
19
README.md
@ -8,9 +8,11 @@ Quick Reference
|
||||
[](https://hub.docker.com/r/wcjiang/reference)
|
||||
<!--rehype:ignore:end-->
|
||||
|
||||
为开发人员分享快速参考备忘清单(主要是方便自己),在看到 [Reference](https://github.com/Randy8080/reference) 快速参考备忘单,感觉非常简单,造轮子使命感突然来了,造个中文版本的,为了方便自己的技术栈查阅,立马撸起来 :)。
|
||||
<!--rehype:ignore:start-->
|
||||
[](https://jaywcjlove.github.io/reference)
|
||||
<!--rehype:ignore:end-->
|
||||
|
||||
如果您发现此处的备忘单不合适,您可以通过提交 [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) 来修复它或提供更好的备忘清单,只针对【中文】用户。以下是开源天使提供的一些备忘清单和快速参考 :)。
|
||||
|
||||
## 编程
|
||||
|
||||
@ -32,10 +34,12 @@ Quick Reference
|
||||
[Electron](./docs/electron.md)<!--rehype:style=background: rgb(0 72 153/var(\-\-bg\-opacity));-->
|
||||
[Emmet](./docs/emmet.md)<!--rehype:style=background: rgb(122 203 23/var(\-\-bg\-opacity));-->
|
||||
[Styled Components](./docs/styled-components.md)<!--rehype:style=background: rgb(221 60 184/var(\-\-bg\-opacity));-->
|
||||
[Stylus](./docs/stylus.md)<!--rehype:style=background: rgb(109 161 63/var(\-\-bg\-opacity));-->
|
||||
[HTML](./docs/html.md)<!--rehype:style=background: rgb(228 77 39/var(\-\-bg\-opacity));-->
|
||||
[JavaScript](./docs/javascript.md)<!--rehype:style=background: rgb(203 183 31/var(\-\-bg\-opacity));-->
|
||||
[Jest](./docs/jest.md)<!--rehype:style=background: rgb(153 66 91/var(\-\-bg\-opacity));-->
|
||||
[Lerna](./docs/lerna.md)<!--rehype:style=background: rgb(192 132 252/var(\-\-bg\-opacity));-->
|
||||
[Less.js](./docs/lessjs.md)<!--rehype:style=background: rgb(29 54 93/var(\-\-bg\-opacity));-->
|
||||
[npm](./docs/npm.md)<!--rehype:style=background: rgb(203 2 0/var(\-\-bg\-opacity));-->
|
||||
[package.json](./docs/package.json.md)<!--rehype:style=background: rgb(132 132 132/var(\-\-bg\-opacity));-->
|
||||
[React](./docs/react.md)<!--rehype:style=background: rgb(34 143 173/var(\-\-bg\-opacity));-->
|
||||
@ -44,6 +48,12 @@ Quick Reference
|
||||
[Vue 2](./docs/vue2.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
## Nodejs
|
||||
|
||||
[Express.js](./docs/expressjs.md)<!--rehype:style=background: rgb(95 151 206/var(\-\-bg\-opacity));-->
|
||||
[Koa.js](./docs/koajs.md)<!--rehype:style=background: rgb(95 151 206/var(\-\-bg\-opacity));-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
## 工具
|
||||
|
||||
[nginx](./docs/nginx.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));-->
|
||||
@ -58,12 +68,14 @@ Quick Reference
|
||||
|
||||
## Linux 命令
|
||||
|
||||
[Chmod](./docs/chmod.md)<!--rehype:style=background: rgb(239 68 113/var(\-\-bg\-opacity));-->
|
||||
[Curl](./docs/curl.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Chmod](./docs/chmod.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Cron](./docs/cron.md)<!--rehype:style=background: rgb(239 68 68/var(\-\-bg\-opacity));-->
|
||||
[Git](./docs/git.md)<!--rehype:style=background: rgb(215 89 62/var(\-\-bg\-opacity));-->
|
||||
[Grep](./docs/grep.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[find](./docs/find.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[htop](./docs/htop.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Home Brew](./docs/homebrew.md)<!--rehype:style=background: rgb(252 185 87/var(\-\-bg\-opacity));-->
|
||||
[Sed](./docs/sed.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[SSH](./docs/ssh.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));-->
|
||||
[Screen](./docs/screen.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));-->
|
||||
@ -72,6 +84,7 @@ Quick Reference
|
||||
## 其它
|
||||
|
||||
[Quick Reference](./docs/quickreference.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Github Actions](./docs/github-actions.md)<!--rehype:style=background: rgb(121 184 255/var(\-\-bg\-opacity));-->
|
||||
[Colors Named](./docs/colors-named.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[HTTP 状态码](./docs/http-status-code.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[HTML 字符实体](./docs/html-char.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
|
@ -1,10 +1,8 @@
|
||||
CSS 备忘清单
|
||||
===
|
||||
|
||||
|
||||
这是一份关于 CSS 优点的快速参考备忘单,列出了选择器语法、属性、单位和其他有用的信息
|
||||
|
||||
|
||||
入门
|
||||
------------
|
||||
|
||||
@ -406,6 +404,8 @@ color: tan;
|
||||
color: rebeccapurple;
|
||||
```
|
||||
|
||||
更多标准[颜色名称](./colors-named.md)
|
||||
|
||||
### 十六进制颜色
|
||||
|
||||
```css
|
||||
|
228
docs/curl.md
Normal file
228
docs/curl.md
Normal file
@ -0,0 +1,228 @@
|
||||
Curl 备忘清单
|
||||
===
|
||||
|
||||
此 [Curl](https://github.com/curl/curl) 备忘清单包含命令和一些常见的 Curl 技巧示例。
|
||||
|
||||
入门
|
||||
----
|
||||
|
||||
### 介绍
|
||||
|
||||
Curl 是一种在服务器之间传输数据的工具,支持协议,包括 HTTP/FTP/IMAP/LDAP/POP3/SCP/SFTP/SMB/SMTP 等
|
||||
|
||||
- [Curl GitHub 源码仓库](https://github.com/curl/curl) _(github.com)_
|
||||
- [Curl 官方网站](https://curl.se/) _(curl.se)_
|
||||
|
||||
|
||||
### Options
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
```bash
|
||||
-o <file> # --output: 写入文件
|
||||
-u user:pass # --user: 验证
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```bash
|
||||
-v # --verbose: 在操作期间使 curl 冗长
|
||||
-vv # 更冗长
|
||||
-s # --silent: 不显示进度表或错误
|
||||
-S # --show-error: 与 --silent (-sS) 一起使用时,显示错误但没有进度表
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```bash
|
||||
-i # --include: 在输出中包含 HTTP 标头
|
||||
-I # --head: 仅标头
|
||||
```
|
||||
|
||||
### 请求
|
||||
|
||||
```bash
|
||||
-X POST # --request
|
||||
-L # 如果页面重定向,请点击链接
|
||||
-F # --form: multipart/form-data 的 HTTP POST 数据
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 数据
|
||||
|
||||
```bash
|
||||
# --data: HTTP post 数据
|
||||
# URL 编码(例如,status="Hello")
|
||||
-d 'data'
|
||||
|
||||
# --data 通过文件
|
||||
-d @file
|
||||
|
||||
# --get: 通过 get 发送 -d 数据
|
||||
-G
|
||||
```
|
||||
|
||||
### 头信息 Headers
|
||||
|
||||
```bash
|
||||
-A <str> # --user-agent
|
||||
|
||||
-b name=val # --cookie
|
||||
|
||||
-b FILE # --cookie
|
||||
|
||||
-H "X-Foo: y" # --header
|
||||
|
||||
--compressed # 使用 deflate/gzip
|
||||
```
|
||||
|
||||
### SSL
|
||||
|
||||
```bash
|
||||
--cacert <file>
|
||||
--capath <dir>
|
||||
```
|
||||
|
||||
```bash
|
||||
-E, --cert <cert> # --cert: 客户端证书文件
|
||||
--cert-type # der/pem/eng
|
||||
-k, --insecure # 对于自签名证书
|
||||
```
|
||||
|
||||
#### 安装
|
||||
|
||||
```bash
|
||||
apk add --update curl # alpine linux 中安装
|
||||
```
|
||||
|
||||
示例
|
||||
----
|
||||
<!--rehype:body-class=cols-6-->
|
||||
|
||||
### CURL GET/HEAD
|
||||
<!--rehype:wrap-class=col-span-4 row-span-2-->
|
||||
|
||||
命令 | 说明
|
||||
:- | :-
|
||||
`curl -I https://www.baidu.com` | `curl` 发请求
|
||||
`curl -v -I https://www.baidu.com` | 带有详细信息的 `curl` 发请求
|
||||
`curl -X GET https://www.baidu.com` | 使用显式 http 方法进行 `curl`
|
||||
`curl --noproxy 127.0.0.1 http://www.stackoverflow.com` | 没有 http 代理的 `curl`
|
||||
`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:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
$ curl -v -include \
|
||||
--form key1=value1 \
|
||||
--form upload=@localfilename URL
|
||||
```
|
||||
|
||||
### 为 curl 响应美化 json 输出
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
$ curl -XGET http://${elasticsearch_ip}:9200/_cluster/nodes | python -m json.tool
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### CURL POST
|
||||
<!--rehype:wrap-class=col-span-4-->
|
||||
|
||||
命令 | 说明
|
||||
:- | :-
|
||||
`curl -d "name=username&password=123456" <URL>` | `curl` 发请求
|
||||
`curl <URL> -H "content-type: application/json" -d "{ \"woof\": \"bark\"}"` | `curl` 发送 json
|
||||
|
||||
### CURL 脚本安装 rvm
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```shell
|
||||
curl -sSL https://get.rvm.io | bash
|
||||
```
|
||||
|
||||
### CURL 高级
|
||||
<!--rehype:wrap-class=col-span-6-->
|
||||
|
||||
命令 | 说明
|
||||
:- | :-
|
||||
`curl -L -s http://ipecho.net/plain, curl -L -s http://whatismijnip.nl` | 获取我的公共 `IP`
|
||||
`curl -u $username:$password http://repo.dennyzhang.com/README.txt` | 带凭证的 `curl`
|
||||
`curl -v -F key1=value1 -F upload=@localfilename <URL>` | `curl` 上传
|
||||
`curl -k -v --http2 https://www.google.com/` | 使用 http2 curl
|
||||
`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:wrap-class=col-span-4-->
|
||||
|
||||
```shell
|
||||
curl -s -w \
|
||||
'\nLookup time:\t%{time_namelookup}\nConnect time:\t%{time_connect}\nAppCon time:\t%{time_appconnect}\nRedirect time:\t%{time_redirect}\nPreXfer time:\t%{time_pretransfer}\nStartXfer time:\t%{time_starttransfer}\n\nTotal time:\t%{time_total}\n' \
|
||||
-o /dev/null https://www.google.com
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 使用 Curl 检查远程资源是否可用
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```bash
|
||||
curl -o /dev/null --silent -Iw "%{http_code}" https://example.com/my.remote.tarball.gz
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 正在下载文件
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
```bash
|
||||
curl https://example.com | \
|
||||
grep --only-matching 'src="[^"]*.[png]"' | \
|
||||
cut -d\" -f2 | \
|
||||
while read i; do curl https://example.com/"${i}" \
|
||||
-o "${i##*/}"; done
|
||||
```
|
||||
|
||||
从站点下载所有 PNG 文件(使用GNU grep)
|
||||
|
||||
### 下载文件,保存文件而不更改其名称
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
```bash
|
||||
curl --remote-name "https://example.com/linux-distro.iso"
|
||||
```
|
||||
|
||||
重命名文件
|
||||
|
||||
```bash
|
||||
curl --remote-name "http://example.com/index.html" --output foo.html
|
||||
```
|
||||
|
||||
### 继续部分下载
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
```bash
|
||||
curl --remote-name --continue-at - "https://example.com/linux-distro.iso"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 从多个域下载文件
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
```bash
|
||||
curl "https://www.{example,w3,iana}.org/index.html" --output "file_#1.html"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 下载一系列文件
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
```bash
|
||||
curl "https://{foo,bar}.com/file_[1-4].webp" --output "#1_#2.webp"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
下载一系列文件(输出`foo_file1.webp`、`foo_file2.webp…bar_file1_webp`等)
|
407
docs/expressjs.md
Normal file
407
docs/expressjs.md
Normal file
@ -0,0 +1,407 @@
|
||||
Express 备忘清单
|
||||
===
|
||||
|
||||
这是用于 Node.js 的快速、不拘一格、极简主义的 Web 框架,包含 [Express.js](http://expressjs.com/) 的 API 参考列表和一些示例。
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### Hello World
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
- 创建项目,添加 `package.json` 配置
|
||||
```bash
|
||||
$ mkdir myapp # 创建目录
|
||||
$ cd myapp # 进入目录
|
||||
$ npm init -y # 初始化一个配置
|
||||
```
|
||||
- 安装依赖
|
||||
```bash
|
||||
$ npm install express # 安装依赖
|
||||
```
|
||||
- 入口文件 `index.js` 添加代码:
|
||||
```js
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
const port = 3000
|
||||
app.get('/', (req, res) => {
|
||||
res.send('Hello World!')
|
||||
})
|
||||
app.listen(port, () => {
|
||||
console.log(`监听端口${port}示例应用`)
|
||||
})
|
||||
```
|
||||
- 使用以下命令运行应用程序
|
||||
```bash
|
||||
$ node index.js
|
||||
```
|
||||
<!--rehype:className=style-timeline-->
|
||||
|
||||
### express -h
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```bash
|
||||
Usage: express [options] [dir]
|
||||
Options:
|
||||
-h, --help 输出使用信息
|
||||
--version 输出版本号
|
||||
-e, --ejs 添加 ejs 引擎支持
|
||||
--hbs 添加 hbs 引擎支持
|
||||
--pug 添加 pug 引擎支持
|
||||
-H, --hogan 添加 hogan.js 引擎支持
|
||||
--no-view 无视图引擎生成
|
||||
-v, --view <engine> 添加视图 <engine> 支持 (ejs|hbs|hjs|jade|pug|twig|vash) (默认jade)
|
||||
-c, --css <engine> 添加样式表 <engine> 支持 (less|stylus|compass|sass) (默认css)
|
||||
--git 添加 .gitignore
|
||||
-f, --force 强制非空目录
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
创建一个 `myapp` 的项目
|
||||
|
||||
```bash
|
||||
$ express --view=pug myapp
|
||||
# 运行应用程序
|
||||
$ DEBUG=myapp:* npm start
|
||||
```
|
||||
|
||||
### express()
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`express.json()` | [#](http://expressjs.com/en/4x/api.html#express.json)
|
||||
`express.raw()` | [#](http://expressjs.com/en/4x/api.html#express.raw)
|
||||
`express.Router()` | [#](http://expressjs.com/en/4x/api.html#express.router)
|
||||
`express.static()` | [#](http://expressjs.com/en/4x/api.html#express.static)
|
||||
`express.text()` | [#](http://expressjs.com/en/4x/api.html#express.text)
|
||||
`express.urlencoded()` | [#](http://expressjs.com/en/4x/api.html#express.urlencoded)
|
||||
|
||||
### Router
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`router.all()` | [#](http://expressjs.com/en/4x/api.html#router.all)
|
||||
`router.METHOD()` | [#](http://expressjs.com/en/4x/api.html#router.METHOD)
|
||||
`router.param()` | [#](http://expressjs.com/en/4x/api.html#router.param)
|
||||
`router.route()` | [#](http://expressjs.com/en/4x/api.html#router.route)
|
||||
`router.use()` | [#](http://expressjs.com/en/4x/api.html#router.use)
|
||||
|
||||
### Application
|
||||
|
||||
```js
|
||||
var express = require('express')
|
||||
var app = express()
|
||||
|
||||
console.dir(app.locals.title)
|
||||
// => 'My App'
|
||||
console.dir(app.locals.email)
|
||||
// => 'me@myapp.com'
|
||||
```
|
||||
|
||||
#### **属性**
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`app.locals` | 应用程序中的局部变量 [#](http://expressjs.com/en/4x/api.html#app.locals)
|
||||
`app.mountpath` | 安装子应用程序的路径模式 [#](http://expressjs.com/en/4x/api.html#app.mountpath)
|
||||
|
||||
#### **Events**
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`mount` | 子应用挂载到父应用上,子应用上触发事件 [#](http://expressjs.com/en/4x/api.html#app.onmount)
|
||||
|
||||
#### **方法**
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`app.all()` | [#](http://expressjs.com/en/4x/api.html#app.all)
|
||||
`app.delete()` | [#](http://expressjs.com/en/4x/api.html#app.delete.method)
|
||||
`app.disable()` | [#](http://expressjs.com/en/4x/api.html#app.disable)
|
||||
`app.disabled()` | [#](http://expressjs.com/en/4x/api.html#app.disabled)
|
||||
`app.enable()` | [#](http://expressjs.com/en/4x/api.html#app.enable)
|
||||
`app.enabled()` | [#](http://expressjs.com/en/4x/api.html#app.enabled)
|
||||
`app.engine()` | [#](http://expressjs.com/en/4x/api.html#app.engine)
|
||||
`app.get(name)` | [#](http://expressjs.com/en/4x/api.html#app.get)
|
||||
`app.get(path, callback)` | [#](http://expressjs.com/en/4x/api.html#app.get.method)
|
||||
`app.listen()` | [#](http://expressjs.com/en/4x/api.html#app.listen)
|
||||
`app.METHOD()` | [#](http://expressjs.com/en/4x/api.html#app.METHOD)
|
||||
`app.param()` | [#](http://expressjs.com/en/4x/api.html#app.param)
|
||||
`app.path()` | [#](http://expressjs.com/en/4x/api.html#app.path)
|
||||
`app.post()` | [#](http://expressjs.com/en/4x/api.html#app.post.method)
|
||||
`app.put()` | [#](http://expressjs.com/en/4x/api.html#app.put.method)
|
||||
`app.render()` | [#](http://expressjs.com/en/4x/api.html#app.render)
|
||||
`app.route()` | [#](http://expressjs.com/en/4x/api.html#app.route)
|
||||
`app.set()` | [#](http://expressjs.com/en/4x/api.html#app.set)
|
||||
`app.use()` | [#](http://expressjs.com/en/4x/api.html#app.use)
|
||||
|
||||
### Request
|
||||
|
||||
#### 属性
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`req.app` | [#](http://expressjs.com/en/4x/api.html#req.app)
|
||||
`req.baseUrl` | [#](http://expressjs.com/en/4x/api.html#req.baseUrl)
|
||||
`req.body` | [#](http://expressjs.com/en/4x/api.html#req.body)
|
||||
`req.cookies` | [#](http://expressjs.com/en/4x/api.html#req.cookies)
|
||||
`req.fresh` | [#](http://expressjs.com/en/4x/api.html#req.fresh)
|
||||
`req.hostname` | [#](http://expressjs.com/en/4x/api.html#req.hostname)
|
||||
`req.ip` | [#](http://expressjs.com/en/4x/api.html#req.ip)
|
||||
`req.ips` | [#](http://expressjs.com/en/4x/api.html#req.ips)
|
||||
`req.method` | [#](http://expressjs.com/en/4x/api.html#req.method)
|
||||
`req.originalUrl` | [#](http://expressjs.com/en/4x/api.html#req.originalUrl)
|
||||
`req.params` | [#](http://expressjs.com/en/4x/api.html#req.params)
|
||||
`req.path` | [#](http://expressjs.com/en/4x/api.html#req.path)
|
||||
`req.protocol` | [#](http://expressjs.com/en/4x/api.html#req.protocol)
|
||||
`req.query` | [#](http://expressjs.com/en/4x/api.html#req.query)
|
||||
`req.route` | [#](http://expressjs.com/en/4x/api.html#req.route)
|
||||
`req.secure` | [#](http://expressjs.com/en/4x/api.html#req.secure)
|
||||
`req.signedCookies` | [#](http://expressjs.com/en/4x/api.html#req.signedCookies)
|
||||
`req.stale` | [#](http://expressjs.com/en/4x/api.html#req.stale)
|
||||
`req.subdomains` | [#](http://expressjs.com/en/4x/api.html#req.subdomains)
|
||||
`req.xhr` | [#](http://expressjs.com/en/4x/api.html#req.xhr)
|
||||
|
||||
#### 方法
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`req.accepts()` | [#](http://expressjs.com/en/4x/api.html#req.accepts)
|
||||
`req.acceptsCharsets()` | [#](http://expressjs.com/en/4x/api.html#req.acceptsCharsets)
|
||||
`req.acceptsEncodings()` | [#](http://expressjs.com/en/4x/api.html#req.acceptsEncodings)
|
||||
`req.acceptsLanguages()` | [#](http://expressjs.com/en/4x/api.html#req.acceptsLanguages)
|
||||
`req.get()` | 获取HTTP 请求头字段 [#](http://expressjs.com/en/4x/api.html#req.get)
|
||||
`req.is()` | [#](http://expressjs.com/en/4x/api.html#req.is)
|
||||
`req.param()` | [#](http://expressjs.com/en/4x/api.html#req.param)
|
||||
`req.range()` | [#](http://expressjs.com/en/4x/api.html#req.range)
|
||||
|
||||
### Response
|
||||
|
||||
```js
|
||||
app.get('/', function (req, res) {
|
||||
console.dir(res.headersSent) // false
|
||||
res.send('OK')
|
||||
console.dir(res.headersSent) // true
|
||||
})
|
||||
```
|
||||
|
||||
#### 属性
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`res.app ` | [#](http://expressjs.com/en/4x/api.html#res.app)
|
||||
`res.headersSent` | [#](http://expressjs.com/en/4x/api.html#res.headersSent)
|
||||
`res.locals` | [#](http://expressjs.com/en/4x/api.html#res.locals)
|
||||
|
||||
#### 方法
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`res.append()` | [#](http://expressjs.com/en/4x/api.html#res.append)
|
||||
`res.attachment()` | [#](http://expressjs.com/en/4x/api.html#res.attachment)
|
||||
`res.cookie()` | [#](http://expressjs.com/en/4x/api.html#res.cookie)
|
||||
`res.clearCookie()` | [#](http://expressjs.com/en/4x/api.html#res.clearCookie)
|
||||
`res.download()` | 提示要下载的文件 [#](http://expressjs.com/en/4x/api.html#res.download)
|
||||
`res.end()` | 结束响应过程 [#](http://expressjs.com/en/4x/api.html#res.end)
|
||||
`res.format()` | [#](http://expressjs.com/en/4x/api.html#res.format)
|
||||
`res.get()` | [#](http://expressjs.com/en/4x/api.html#res.get)
|
||||
`res.json()` | 发送 JSON 响应 [#](http://expressjs.com/en/4x/api.html#res.json)
|
||||
`res.jsonp()` | 发送带有 JSONP 支持的响应 [#](http://expressjs.com/en/4x/api.html#res.jsonp)
|
||||
`res.links()` | [#](http://expressjs.com/en/4x/api.html#res.links)
|
||||
`res.location()` | [#](http://expressjs.com/en/4x/api.html#res.location)
|
||||
`res.redirect()` | 重定向请求 [#](http://expressjs.com/en/4x/api.html#res.redirect)
|
||||
`res.render()` | 渲染视图模板 [#](http://expressjs.com/en/4x/api.html#res.render)
|
||||
`res.send()` | 发送各种类型的响应 [#](http://expressjs.com/en/4x/api.html#res.send)
|
||||
`res.sendFile()` | 将文件作为八位字节流发送 [#](http://expressjs.com/en/4x/api.html#res.sendFile)
|
||||
`res.sendStatus()` | [#](http://expressjs.com/en/4x/api.html#res.sendStatus)
|
||||
`res.set()` | [#](http://expressjs.com/en/4x/api.html#res.set)
|
||||
`res.status()` | [#](http://expressjs.com/en/4x/api.html#res.status)
|
||||
`res.type()` | [#](http://expressjs.com/en/4x/api.html#res.type)
|
||||
`res.vary()` | [#](http://expressjs.com/en/4x/api.html#res.vary)
|
||||
|
||||
示例
|
||||
----
|
||||
|
||||
### Router
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
为传递给此路由器的任何请求调用
|
||||
|
||||
```js
|
||||
router.use(function (req, res, next) {
|
||||
// .. 这里有一些逻辑 .. 像任何其他中间件一样
|
||||
next()
|
||||
})
|
||||
```
|
||||
|
||||
将处理任何以 `/events` 结尾的请求
|
||||
|
||||
```js
|
||||
// 取决于路由器在哪里 "use()"
|
||||
router.get('/events', (req, res, next) => {
|
||||
// ..
|
||||
})
|
||||
```
|
||||
|
||||
### Response
|
||||
|
||||
`res` 对象表示 `Express` 应用程序在收到 HTTP 请求时发送的 HTTP 响应
|
||||
|
||||
```js
|
||||
app.get('/user/:id', (req, res) => {
|
||||
res.send('user ' + req.params.id)
|
||||
})
|
||||
```
|
||||
|
||||
### Request
|
||||
|
||||
`req` 对象表示 `HTTP` 请求,并具有请求查询字符串、参数、正文、HTTP 标头等的属性
|
||||
|
||||
```js
|
||||
app.get('/user/:id', (req, res) => {
|
||||
res.send('user ' + req.params.id)
|
||||
})
|
||||
```
|
||||
|
||||
### res.end()
|
||||
|
||||
```js
|
||||
res.end()
|
||||
res.status(404).end()
|
||||
```
|
||||
|
||||
结束响应过程。这个方法其实来自 Node 核心,具体是 `http.ServerResponse` 的 `response.end()` 方法
|
||||
|
||||
### res.json([body])
|
||||
|
||||
```js
|
||||
res.json(null)
|
||||
res.json({ user: 'tobi' })
|
||||
res.status(500).json({ error: 'message' })
|
||||
```
|
||||
|
||||
### app.all
|
||||
|
||||
```js
|
||||
app.all('/secret', function (req, res, next) {
|
||||
console.log('访问秘密部分...')
|
||||
next() // 将控制权传递给下一个处理程序
|
||||
})
|
||||
```
|
||||
|
||||
### app.delete
|
||||
|
||||
```js
|
||||
app.delete('/', function (req, res) {
|
||||
res.send('DELETE request to homepage')
|
||||
})
|
||||
```
|
||||
|
||||
### app.disable(name)
|
||||
|
||||
```js
|
||||
app.disable('trust proxy')
|
||||
app.get('trust proxy')
|
||||
// => false
|
||||
```
|
||||
|
||||
### app.disabled(name)
|
||||
|
||||
```js
|
||||
app.disabled('trust proxy')
|
||||
// => true
|
||||
|
||||
app.enable('trust proxy')
|
||||
app.disabled('trust proxy')
|
||||
// => false
|
||||
```
|
||||
|
||||
### app.engine(ext, callback)
|
||||
|
||||
```js
|
||||
var engines = require('consolidate')
|
||||
|
||||
app.engine('haml', engines.haml)
|
||||
app.engine('html', engines.hogan)
|
||||
```
|
||||
|
||||
### app.listen([port[, host[, backlog]]][, callback])
|
||||
|
||||
```js
|
||||
var express = require('express')
|
||||
|
||||
var app = express()
|
||||
app.listen(3000)
|
||||
```
|
||||
|
||||
### 路由
|
||||
|
||||
```js
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
|
||||
// 向主页发出 GET 请求时响应“hello world”
|
||||
app.get('/', (req, res) => {
|
||||
res.send('hello world')
|
||||
})
|
||||
```
|
||||
|
||||
```js
|
||||
// GET 方法路由
|
||||
app.get('/', (req, res) => {
|
||||
res.send('GET request to the homepage')
|
||||
})
|
||||
|
||||
// POST 方法路由
|
||||
app.post('/', (req, res) => {
|
||||
res.send('POST request to the homepage')
|
||||
})
|
||||
```
|
||||
|
||||
### 中间件
|
||||
|
||||
```js
|
||||
function logOriginalUrl (req, res, next) {
|
||||
console.log('ReqURL:', req.originalUrl)
|
||||
next()
|
||||
}
|
||||
|
||||
function logMethod (req, res, next) {
|
||||
console.log('Request Type:', req.method)
|
||||
next()
|
||||
}
|
||||
|
||||
const log = [logOriginalUrl, logMethod]
|
||||
|
||||
app.get('/user/:id', log,
|
||||
(req, res, next)=>{
|
||||
res.send('User Info')
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### 使用模版
|
||||
|
||||
```js
|
||||
app.set('view engine', 'pug')
|
||||
```
|
||||
|
||||
在 `views` 目录下创建一个名为 `index.pug` 的 `Pug` 模板文件,内容如下
|
||||
|
||||
```pug
|
||||
html
|
||||
head
|
||||
title= title
|
||||
body
|
||||
h1= message
|
||||
```
|
||||
|
||||
创建一个路由来渲染 `index.pug` 文件。如果未设置视图引擎属性,则必须指定视图文件的扩展名
|
||||
|
||||
```js
|
||||
app.get('/', (req, res) => {
|
||||
res.render('index', {
|
||||
title: 'Hey', message: 'Hello there!'
|
||||
})
|
||||
})
|
||||
```
|
@ -423,7 +423,7 @@ $ git config --global alias.ci commit
|
||||
$ git config --global alias.st status
|
||||
```
|
||||
|
||||
也可以看看:[More Aliases](https://gist.github.com/johnpolacek/69604a1f6861129ef088)
|
||||
也可以看看:[更多别名](https://gist.github.com/johnpolacek/69604a1f6861129ef088)
|
||||
|
||||
### 设置大小写敏感
|
||||
|
||||
|
774
docs/github-actions.md
Normal file
774
docs/github-actions.md
Normal file
@ -0,0 +1,774 @@
|
||||
Github Actions 备忘清单
|
||||
====
|
||||
|
||||
本备忘单总结了 [Github Actions](https://github.com/actions) 常用的配置说明,以供快速参考。
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### 介绍
|
||||
|
||||
GitHub [Actions](https://github.com/actions) 的仓库中自动化、自定义和执行软件开发工作流程,有四个基本的概念,如下:
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`workflow` _(工作流程)_ | 持续集成一次运行的过程,就是一个 `workflow`
|
||||
`job` _(任务)_ | 一个 `workflow` 由一个或多个 `jobs` 构成,含义是一次持续集成的运行,可以完成多个任务
|
||||
`step` _(步骤)_ | 每个 `job` 由多个 `step` 构成,一步步完成
|
||||
`action` _(动作)_ | 每个 `step` 可以依次执行一个或多个命令(`action`)
|
||||
<!--rehype:className=style-list-arrow-->
|
||||
|
||||
---
|
||||
|
||||
- 采用 [YAML](./yaml.md) 格式定义配置文件
|
||||
- 存放在代码仓库的 `.github/workflows` 目录中
|
||||
- 后缀名统一为 `.yml`,比如 `ci.yml`
|
||||
- 一个库可以有多个 `workflow` 文件
|
||||
- 根据配置事件自动运行配置文件
|
||||
<!--rehype:className=style-round-->
|
||||
|
||||
### 配置文件
|
||||
|
||||
```yaml {3,5,10}
|
||||
name: GitHub Actions Demo
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
# 任务
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
# 步骤 根据步骤执行任务
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
|
||||
- run: npm install
|
||||
- run: npm run build
|
||||
```
|
||||
|
||||
存放到 `.github/workflows` 目录中,命名为 `ci.yml`,当 `push` 代码到仓库 `main` 分支中,该配置自动运行配置。
|
||||
|
||||
### 指定触发
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
`push` 事件触发 `workflow`
|
||||
|
||||
```yaml
|
||||
on: push
|
||||
```
|
||||
|
||||
`push` 事件或 `pull_request` 事件都可以触发 `workflow`
|
||||
|
||||
```yaml
|
||||
on: [push, pull_request]
|
||||
```
|
||||
|
||||
只有在 `main` 分支 `push` 事件触发 `workflow`
|
||||
|
||||
```yaml {2}
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
```
|
||||
|
||||
`push` 事件触发 `workflow`,`docs` 目录下的更改 `push` 事件不触发 `workflow`
|
||||
|
||||
```yaml {2,4}
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
```
|
||||
|
||||
push 事件触发 workflow,包括 sub-project 目录或其子目录中的文件触发 workflow,除非该文件在 sub-project/docs 目录中,不触发 workflow
|
||||
|
||||
```yaml
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'sub-project/**'
|
||||
- '!sub-project/docs/**'
|
||||
```
|
||||
|
||||
版本发布为 `published` 时运行工作流程。
|
||||
|
||||
```yml
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
```
|
||||
|
||||
### 多项任务
|
||||
|
||||
```yml
|
||||
jobs:
|
||||
my_first_job: # 第一个任务
|
||||
name: My first job
|
||||
|
||||
my_second_job: # 第二个任务
|
||||
name: My second job
|
||||
```
|
||||
|
||||
通过 jobs `(jobs.<job_id>.name)`字段,配置一项或多项需要执行的任务
|
||||
|
||||
### 多项任务依赖关系
|
||||
|
||||
通过 needs `(jobs.<job_id>.needs)`字段,指定当前任务的依赖关系
|
||||
|
||||
```yml
|
||||
jobs:
|
||||
job1:
|
||||
job2:
|
||||
needs: job1
|
||||
job3:
|
||||
needs: [job1, job2]
|
||||
```
|
||||
|
||||
上面配置中,`job1` 必须先于 `job2` 完成,而 `job3` 等待 `job1` 和 `job2` 的完成才能运行。因此,这个 `workflow` 的运行顺序依次为:`job1`、`job2`、`job3`
|
||||
|
||||
### 多项任务传递参数
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```yml {2,5,9,11,15}
|
||||
jobs:
|
||||
job1:
|
||||
runs-on: ubuntu-latest
|
||||
# 将步骤输出映射到作业输出
|
||||
outputs:
|
||||
output1: ${{ steps.step1.outputs.test }}
|
||||
output2: ${{ steps.step2.outputs.test }}
|
||||
steps:
|
||||
- id: step1
|
||||
run: echo "::set-output name=test::hello"
|
||||
- id: step2
|
||||
run: echo "::set-output name=test::world"
|
||||
job2:
|
||||
runs-on: ubuntu-latest
|
||||
needs: job1
|
||||
steps:
|
||||
- run: echo ${{needs.job1.outputs.output1}} ${{needs.job1.outputs.output2}}
|
||||
```
|
||||
|
||||
### 指定每项任务的虚拟机环境
|
||||
|
||||
```yml
|
||||
runs-on: ubuntu-latest
|
||||
```
|
||||
|
||||
指定运行所需要的虚拟机环境,⚠️ 它是必填字段
|
||||
|
||||
```yml {3}
|
||||
jobs:
|
||||
build: # 任务名称
|
||||
runs-on: ubuntu-latest # 虚拟机环境配置
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
- `Windows Server 2022` _(windows-latest)_ 或 _(windows-2022)_
|
||||
- `Ubuntu 20.04` _(ubuntu-latest)_ 或 _(ubuntu-20.04)_
|
||||
- `macOS Monterey 12` _(macos-12)_
|
||||
- `macOS Big Sur 11` _(macos-latest)_,_(macos-11)_
|
||||
<!--rehype:className=style-arrow-->
|
||||
|
||||
另见: [选择 GitHub 托管的运行器](https://docs.github.com/cn/actions/using-workflows/workflow-syntax-for-github-actions#选择-github-托管的运行器)
|
||||
|
||||
### 指定每项任务的步骤
|
||||
|
||||
每个步骤都可以指定以下三个字段
|
||||
|
||||
```shell
|
||||
jobs.<job_id>.steps.name # 步骤名称
|
||||
# 该步骤运行的命令或者 action
|
||||
jobs.<job_id>.steps.run
|
||||
# 该步骤所需的环境变量
|
||||
jobs.<job_id>.steps.env
|
||||
```
|
||||
|
||||
`steps` 字段指定每个 `Job` 的运行步骤,可以包含一个或多个步骤(`steps`)
|
||||
|
||||
```yml {4}
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
|
||||
- run: npm install
|
||||
- run: npm run build
|
||||
```
|
||||
|
||||
### 环境变量
|
||||
|
||||
```shell
|
||||
jobs.<job_id>.environment
|
||||
```
|
||||
使用单一环境名称的示例
|
||||
|
||||
```yml
|
||||
environment: staging_environment
|
||||
```
|
||||
|
||||
使用环境名称和 URL 的示例
|
||||
|
||||
```yml
|
||||
environment:
|
||||
name: production_environment
|
||||
url: https://github.com
|
||||
```
|
||||
|
||||
#### 自定义环境变量
|
||||
|
||||
`GitHub` 会保留 `GITHUB_` 环境变量前缀供 `GitHub` 内部使用。设置有 `GITHUB_` 前缀的环境变量或密码将导致错误。
|
||||
|
||||
```yml
|
||||
- name: 测试 nodejs 获取环境变量
|
||||
env:
|
||||
API_TOKEN: ${{ secrets.API_TOKEN }}
|
||||
```
|
||||
|
||||
在 `https://github.com/<用户名>/<项目名称>/settings/secrets` 中添加 `secrets` `API_TOKEN`,在工作流中设置环境变量 [`API_TOKEN`](https://github.com/jaywcjlove/github-actions/blob/799b232fca3d9df0272eaa12610f9ebfca51b288/.github/workflows/ci.yml#L46)
|
||||
|
||||
### 表达式
|
||||
|
||||
在 `if` 条件下使用表达式时,可以省略表达式语法 (`${{ }}`),因为 GitHub 会自动将 `if` 条件作为表达式求值
|
||||
|
||||
```yml {3}
|
||||
steps:
|
||||
- uses: actions/hello-world-action@v1.1
|
||||
if: github.repository == 'uiw/uiw-repo'
|
||||
# if: ${{ <expression> }}
|
||||
```
|
||||
|
||||
设置环境变量的示例
|
||||
|
||||
|
||||
```yml
|
||||
env:
|
||||
MY_ENV_VAR: ${{ <expression> }}
|
||||
```
|
||||
|
||||
#### 操作符
|
||||
|
||||
- `( )` _(逻辑分组)_
|
||||
- `[ ]` _(指数)_
|
||||
- `.` _(属性取消引用)_
|
||||
- `!` _(不是)_
|
||||
- `<` _(少于)_
|
||||
- `<=` _(小于或等于)_
|
||||
- `>` _(比...更棒)_
|
||||
- `>=` _(大于或等于)_
|
||||
- `==` _(平等的)_
|
||||
- `!=` _(不相等)_
|
||||
- `&&` _(和)_
|
||||
- `||` _(或者)_
|
||||
<!--rehype:className=cols-2 style-none-->
|
||||
|
||||
### Github 上下文
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
属性名称 | 类型 | 描述
|
||||
---- | ---- | ----
|
||||
`github` _(object)_ | 工作流程中任何作业或步骤期间可用的顶层上下文。
|
||||
`github.event` _(object)_ | 完整事件 web 挂钩有效负载。 更多信息请参阅“触发工作流程的事件”。
|
||||
`github.event_path` _(string)_ | 运行器上完整事件 web 挂钩有效负载的路径。
|
||||
`github.workflow` _(string)_ | 工作流程的名称。 如果工作流程文件未指定 name,此属性的值将是仓库中工作流程文件的完整路径。
|
||||
`github.job` _(string)_ | 当前作业的 job_id。
|
||||
`github.run_id` _(string)_ | 仓库中每个运行的唯一编号。 如果您重新执行工作流程运行,此编号不变。
|
||||
`github.run_number` _(string)_ | 仓库中特定工作流程每个运行的唯一编号。 此编号从 1(对应于工作流程的第一个运行)开始,然后随着每个新的运行而递增。 如果您重新执行工作流程运行,此编号不变。
|
||||
`github.actor` _(string)_ | 发起工作流程运行的用户的登录名。
|
||||
`github.repository` _(string)_ | 所有者和仓库名称。 例如 Codertocat/Hello-World。
|
||||
`github.repository_owner` _(string)_ | 仓库所有者的名称。 例如 Codertocat。
|
||||
`github.event_name` _(string)_ | 触发工作流程运行的事件的名称。
|
||||
`github.sha` _(string)_ | 触发工作流程的提交 SHA。
|
||||
`github.ref` _(string)_ | 触发工作流程的分支或标记参考。
|
||||
`github.head_ref` _(string)_ | 工作流程运行中拉取请求的 head_ref 或来源分支。 此属性仅在触发工作流程运行的事件为 pull_request 时才可用。
|
||||
`github.base_ref` _(string)_ | 工作流程运行中拉取请求的 base_ref 或目标分支。 此属性仅在触发工作流程运行的事件为 pull_request 时才可用。
|
||||
`github.token` _(string)_ | 代表仓库上安装的 GitHub 应用程序进行身份验证的令牌。 这在功能上等同于 GITHUB_TOKEN 密码。 更多信息请参阅“使用 GITHUB_TOKEN 验证身份”。
|
||||
`github.workspace` _(string)_ | 使用 checkout 操作时步骤的默认工作目录和仓库的默认位置。
|
||||
`github.action` _(string)_ | 正在运行的操作的名称。 在当前步骤运行脚本时,GitHub 删除特殊字符或使用名称 run。 如果在同一作业中多次使用相同的操作,则名称将包括带有序列号的后缀。 例如,运行的第一个脚本名称为 run1,则第二个脚本将命名为 run2。 同样,actions/checkout 第二次调用时将变成 actionscheckout2。
|
||||
<!--rehype:className=style-list-arrow-->
|
||||
|
||||
[Github 上下文](https://help.github.com/cn/actions/reference/context-and-expression-syntax-for-github-actions)是访问有关工作流运行、运行器环境、作业和步骤的信息的一种方式
|
||||
|
||||
### 默认环境变量
|
||||
|
||||
环境变量 | 描述
|
||||
---- | ----
|
||||
`CI` | 始终设置为 `true`
|
||||
`HOME` | 用于存储用户数据的 GitHub 主目录路径。 例如 `/github/home`
|
||||
`GITHUB_WORKFLOW` | 工作流程的名称。
|
||||
`GITHUB_RUN_ID` | 仓库中每个运行的唯一编号。 如果您重新执行工作流程运行,此编号不变。
|
||||
`GITHUB_RUN_NUMBER` | 仓库中特定工作流程每个运行的唯一编号。 此编号从 1(对应于工作流程的第一个运行)开始,然后随着每个新的运行而递增。 如果您重新执行工作流程运行,此编号不变。
|
||||
`GITHUB_ACTION` | 操作唯一的标识符 (id)。
|
||||
`GITHUB_ACTIONS` | 当 GitHub 操作 运行工作流程时,始终设置为 true。 您可以使用此变量来区分测试是在本地运行还是通过 GitHub 操作 运行。
|
||||
`GITHUB_ACTION_PATH` | GitHub 操作所在的路径
|
||||
`GITHUB_ACTOR` | 发起工作流程的个人或应用程序的名称。 例如 octocat
|
||||
`GITHUB_API_URL` | 返回 `API URL`。例如:`https://api.github.com`
|
||||
`GITHUB_REPOSITORY` | 所有者和仓库名称。 例如 octocat/Hello-World
|
||||
`GITHUB_EVENT_NAME` | 触发工作流程的 web 挂钩事件的名称
|
||||
`GITHUB_EVENT_PATH` | 具有完整 web 挂钩事件有效负载的文件路径。 例如 /github/workflow/event.json
|
||||
`GITHUB_WORKSPACE` | GitHub 工作空间目录路径。 如果您的工作流程使用 [actions/checkout](https://github.com/actions/checkout) 操作,工作空间目录将包含存储仓库副本的子目录。 如果不使用 [actions/checkout](https://github.com/actions/checkout) 操作,该目录将为空。 例如 /home |/runner/work/my-repo-name/my-repo-name
|
||||
`GITHUB_SHA` | 触发工作流程的提交 SHA。 例如 ffac537e6cbbf9
|
||||
`GITHUB_REF` | 触发工作流程的分支或标记参考。 例如 refs/heads/feature-branch-1。 如果分支或标记都不适用于事件类型,则变量不会存在
|
||||
`GITHUB_HEAD_REF` | 仅为复刻的仓库设置。头部仓库的分支
|
||||
`GITHUB_BASE_REF` | 仅为复刻的仓库设置。基础仓库的分支
|
||||
<!--rehype:className=style-list-arrow-->
|
||||
|
||||
另见: [默认环境变量](https://docs.github.com/cn/actions/learn-github-actions/environment-variables#default-environment-variables)
|
||||
|
||||
### 直接常量
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
作为表达式的一部分,可以使用 `boolean`, `null`, `number` 或 `string`数据类型
|
||||
|
||||
```yml
|
||||
env:
|
||||
myNull: ${{ null }}
|
||||
myBoolean: ${{ false }}
|
||||
myIntegerNumber: ${{ 711 }}
|
||||
myFloatNumber: ${{ -9.2 }}
|
||||
myHexNumber: ${{ 0xff }}
|
||||
myExponentialNumber: ${{ -2.99e-2 }}
|
||||
myString: Mona the Octocat
|
||||
myStringInBraces: ${{ 'It''s open source!' }}
|
||||
```
|
||||
|
||||
### 函数 contains
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
使用字符串的示例
|
||||
|
||||
```js
|
||||
contains('Hello world', 'llo') // 返回 true
|
||||
```
|
||||
|
||||
使用对象过滤器的示例返回 true
|
||||
|
||||
```js
|
||||
contains(github.event.issue.labels.*.name, 'bug')
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
另见: [函数 contains](https://docs.github.com/cn/actions/learn-github-actions/expressions#contains)
|
||||
|
||||
### 函数 startsWith
|
||||
|
||||
```js
|
||||
startsWith('Hello world', 'He') // 返回 true
|
||||
```
|
||||
|
||||
另见: [函数 startsWith](https://docs.github.com/cn/actions/learn-github-actions/expressions#startswith),此函数不区分大小写
|
||||
|
||||
### 函数 format
|
||||
|
||||
```js
|
||||
format('{{Hello {0} {1} {2}!}}', 'Mona', 'the', 'Octocat')
|
||||
// 返回 '{Hello Mona the Octocat!}'.
|
||||
```
|
||||
|
||||
另见: [函数 format](https://docs.github.com/cn/actions/learn-github-actions/expressions#format)
|
||||
|
||||
### 函数 join
|
||||
|
||||
```js
|
||||
join(github.event.issue.labels.*.name, ', ')
|
||||
// 也许返回 'bug, help wanted'.
|
||||
```
|
||||
|
||||
另见: [函数 join](https://docs.github.com/cn/actions/learn-github-actions/expressions#join)
|
||||
|
||||
### 函数 toJSON
|
||||
|
||||
```js
|
||||
toJSON(job)
|
||||
// 也许返回 { "status": "Success" }.
|
||||
```
|
||||
|
||||
另见: [函数 toJSON](https://docs.github.com/cn/actions/learn-github-actions/expressions#tojson)
|
||||
|
||||
### 函数
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`fromJSON` | 返回 JSON 对象或 JSON 数据类型的值 [#](https://docs.github.com/cn/actions/learn-github-actions/expressions#fromjson)
|
||||
`hashFiles` | 返回与路径模式匹配的文件集的单个哈希 [#](https://docs.github.com/cn/actions/learn-github-actions/expressions#hashfiles)
|
||||
`success` | 当前面的步骤都没失败或被取消时返回 true [#](https://docs.github.com/cn/actions/learn-github-actions/expressions#success)
|
||||
`always` | 使步骤始终执行,返回 `true` 即使取消也是如此 [#](https://docs.github.com/cn/actions/learn-github-actions/expressions#always)
|
||||
`cancelled` | 如果工作流被取消,则返回 true [#](https://docs.github.com/cn/actions/learn-github-actions/expressions#cancelled)
|
||||
`failure` | 当作业的任何先前步骤失败时返回 true [#](https://docs.github.com/cn/actions/learn-github-actions/expressions#failure)
|
||||
|
||||
### 函数 success()
|
||||
|
||||
```yml
|
||||
steps:
|
||||
...
|
||||
- name: The job has succeeded
|
||||
if: ${{ success() }}
|
||||
```
|
||||
|
||||
### 函数 failure()
|
||||
|
||||
```yml
|
||||
steps:
|
||||
...
|
||||
- name: The job has failed
|
||||
if: ${{ failure() }}
|
||||
```
|
||||
|
||||
常用实例
|
||||
----
|
||||
|
||||
### 获取版本信息
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```yml
|
||||
- name: Test
|
||||
run: |
|
||||
# Strip git ref prefix from version
|
||||
echo "${{ github.ref }}"
|
||||
# VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
|
||||
|
||||
# # Strip "v" prefix from tag name
|
||||
# [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
|
||||
echo "$VERSION"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 提交到 gh-pages 分支
|
||||
|
||||
```yml
|
||||
- name: Deploy
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{secrets.GITHUB_TOKEN}}
|
||||
publish_dir: ./build
|
||||
```
|
||||
|
||||
### 修改 package.json
|
||||
|
||||
```yml
|
||||
- name: Modify Version
|
||||
shell: bash
|
||||
run: |
|
||||
node -e 'var pkg = require("./package.json"); pkg.version= (new Date().getFullYear().toString().substr(2)) + "." + (new Date().getMonth() + 1) + "." + (new Date().getDate()); require("fs").writeFileSync("./package.json", JSON.stringify(pkg, null, 2))'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
使用 [github-action-package](https://github.com/jaywcjlove/github-action-package) 修改 `name` 字段
|
||||
|
||||
```yml
|
||||
- name: package.json info
|
||||
uses: jaywcjlove/github-action-package@main
|
||||
with:
|
||||
rename: '@wcj/github-package-test'
|
||||
```
|
||||
|
||||
### 克隆带有 Submodule 的仓库
|
||||
|
||||
```yml
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: main
|
||||
submodules: true
|
||||
```
|
||||
|
||||
`submodules`:`true` 检出子模块或 `recursive` 递归检出子模块
|
||||
|
||||
```yml
|
||||
- name: Clone sub repository
|
||||
shell: bash
|
||||
run: |
|
||||
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
|
||||
# git submodule sync --recursive
|
||||
# git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --remote --force --recursive --checkout ant.design
|
||||
```
|
||||
|
||||
### 步骤依赖作业
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
使用 `jobs.<job_id>.needs` 识别在此作业运行之前必须成功完成的任何作业。它可以是一个字符串,也可以是字符串数组。 如果某个作业失败,则所有需要它的作业都会被跳过,除非这些作业使用让该作业继续的条件表达式。
|
||||
|
||||
```yml
|
||||
jobs:
|
||||
job1:
|
||||
job2:
|
||||
needs: job1
|
||||
job3:
|
||||
needs: [job1, job2]
|
||||
```
|
||||
|
||||
在此示例中,`job1` 必须在 `job2` 开始之前成功完成,而 `job3` 要等待 `job1` 和 `job2` 完成。此示例中的作业按顺序运行:
|
||||
|
||||
```
|
||||
❶ job1
|
||||
❷ job2
|
||||
❸ job3
|
||||
```
|
||||
|
||||
配置如下
|
||||
|
||||
```yml
|
||||
jobs:
|
||||
job1:
|
||||
job2:
|
||||
needs: job1
|
||||
job3:
|
||||
if: ${{ always() }}
|
||||
needs: [job1, job2]
|
||||
```
|
||||
|
||||
在此示例中,`job3` 使用 `always()` 条件表达式,因此它始终在 `job1` 和 `job2` 完成后运行,不管它们是否成功。
|
||||
|
||||
### 同步 Gitee
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```yml
|
||||
- name: Sync to Gitee
|
||||
run: |
|
||||
mirror() {
|
||||
git clone "https://github.com/$1/$2"
|
||||
cd "$2"
|
||||
git remote add gitee "https://jaywcjlove:${{ secrets.GITEE_TOKEN }}@gitee.com/uiw/$2"
|
||||
git remote set-head origin -d
|
||||
git push gitee --prune +refs/remotes/origin/*:refs/heads/* +refs/tags/*:refs/tags/*
|
||||
cd ..
|
||||
}
|
||||
mirror uiwjs uiw
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 提交 NPM 包
|
||||
|
||||
```yml
|
||||
- run: npm publish --access public
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
||||
```
|
||||
|
||||
获取 `NPM_TOKEN`,可以通过 [npm](https://www.npmjs.com/settings/wcjiang/tokens) 账号创建 `token`
|
||||
|
||||
```shell
|
||||
npm token list [--json|--parseable] # 查看
|
||||
npm token create [--read-only] [--cidr=1.1.1.1/24,2.2.2.2/16] # 创建
|
||||
npm token revoke <id|token> # 撤销
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
可以使用 [JS-DevTools/npm-publish](https://github.com/JS-DevTools/npm-publish) 提交
|
||||
|
||||
```yml
|
||||
- name: 📦 @province-city-china/data
|
||||
uses: JS-DevTools/npm-publish@v1
|
||||
with:
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
package: packages/data/package.json
|
||||
```
|
||||
|
||||
它有个好处,检测 `package.json` 中版本号是否发生变更,来决定是否提交版本,不会引发流程错误。
|
||||
|
||||
### 步骤作业文件共享
|
||||
|
||||
Artifacts 是 GitHub Actions 为您提供持久文件并在运行完成后使用它们或在作业(文档)之间共享的一种方式。
|
||||
|
||||
要创建工件并使用它,您将需要不同的操作:上传和下载。
|
||||
要上传文件或目录,您只需像这样使用它:
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: mkdir -p path/to/artifact
|
||||
- run: echo hello > path/to/artifact/a.txt
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: my-artifact
|
||||
path: path/to/artifact/a.txt
|
||||
```
|
||||
|
||||
然后下载 `artifact` 以使用它:
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: my-artifact
|
||||
```
|
||||
|
||||
### Node.js
|
||||
|
||||
```yml
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 14
|
||||
```
|
||||
|
||||
使用[矩阵策略](https://docs.github.com/cn/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategy) 在 nodejs 不同版本中运行
|
||||
|
||||
```yml
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [10.x, 12.x, 14.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: 使用 Node ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm ci
|
||||
- run: npm run build --if-present
|
||||
- run: npm test
|
||||
```
|
||||
|
||||
### 提交 docker 镜像
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
```yml
|
||||
# https://www.basefactor.com/github-actions-docker
|
||||
- name: Docker login
|
||||
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build ant.design image
|
||||
run: |
|
||||
cd ./ant\.design
|
||||
docker build -t ant.design .
|
||||
- name: Tags & Push docs
|
||||
run: |
|
||||
# Strip git ref prefix from version
|
||||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
|
||||
|
||||
# Strip "v" prefix from tag name
|
||||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
|
||||
|
||||
docker tag ant.design ${{ secrets.DOCKER_USER }}/ant.design:$VERSION
|
||||
docker tag ant.design ${{ secrets.DOCKER_USER }}/ant.design:latest
|
||||
docker push ${{ secrets.DOCKER_USER }}/ant.design:$VERSION
|
||||
docker push ${{ secrets.DOCKER_USER }}/ant.design:latest
|
||||
```
|
||||
|
||||
### 创建一个 tag
|
||||
|
||||
```yml
|
||||
- name: Create Tag
|
||||
id: create_tag
|
||||
uses: jaywcjlove/create-tag-action@main
|
||||
with:
|
||||
package-path: ./package.json
|
||||
```
|
||||
|
||||
根据 `package-path` 指定的 `package.json` 检测 `version` 是否发生变化来创建 `tag`
|
||||
|
||||
### 生成 git 提交日志
|
||||
|
||||
```yml
|
||||
- name: Generate Changelog
|
||||
id: changelog
|
||||
uses: jaywcjlove/changelog-generator@main
|
||||
with:
|
||||
filter-author: (小弟调调™)
|
||||
|
||||
- name: Get the changelog
|
||||
run: echo "${{ steps.changelog.outputs.changelog }}"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 提交到 GitHub docker 镜像仓库
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
```yml
|
||||
- name: '登录到 GitHub 注册表'
|
||||
run: echo ${{ github.token }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
||||
|
||||
- name: '编译 docker image'
|
||||
run: docker build -t ghcr.io/jaywcjlove/reference:latest .
|
||||
|
||||
- name: '推送到 GitHub 注册表中'
|
||||
run: docker push ghcr.io/jaywcjlove/reference:latest
|
||||
|
||||
- name: '标记 docker 镜像并发布到 GitHub 注册表'
|
||||
if: steps.create_tag.outputs.successful
|
||||
run: |
|
||||
echo "version: v${{ steps.changelog.outputs.version }}"
|
||||
docker tag ghcr.io/jaywcjlove/reference:latest ghcr.io/jaywcjlove/reference:${{steps.changelog.outputs.version}}
|
||||
docker push ghcr.io/jaywcjlove/reference:${{steps.changelog.outputs.version}}
|
||||
```
|
||||
|
||||
### 提交 commit 到 master 分支
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```yml
|
||||
- name: 生成一个文件,并将它提交到 master 分支
|
||||
run: |
|
||||
# Strip git ref prefix from version
|
||||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
|
||||
COMMIT=released-${VERSION}
|
||||
# Strip "v" prefix from tag name
|
||||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
|
||||
echo "输出版本号:$VERSION"
|
||||
# 将版本输出到当前 VERSION 文件中
|
||||
echo "$VERSION" > VERSION
|
||||
echo "1. 输出Commit:$commit"
|
||||
echo "2. Released $VERSION"
|
||||
git fetch
|
||||
git config --local user.email "action@github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
git add .
|
||||
git commit -am $COMMIT
|
||||
git branch -av
|
||||
git pull origin master
|
||||
|
||||
- name: 将上面的提交 push 到 master 分支
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
### 作业之间共享数据
|
||||
|
||||
创建一个文件,然后将其作为构件上传
|
||||
|
||||
```yml {11}
|
||||
jobs:
|
||||
example-job:
|
||||
name: Save output
|
||||
steps:
|
||||
- shell: bash
|
||||
run: |
|
||||
expr 1 + 1 > output.log
|
||||
- name: Upload output file
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: output-log-file
|
||||
path: output.log
|
||||
```
|
||||
|
||||
可以下载名为 `output-log-file` 的工件
|
||||
|
||||
```yml {7}
|
||||
jobs:
|
||||
example-job:
|
||||
steps:
|
||||
- name: Download a single artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: output-log-file
|
||||
```
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
- [Github Actions 学习笔记](https://jaywcjlove.github.io/github-actions) _(jaywcjlove.github.io)_
|
||||
- [了解 GitHub Actions](https://docs.github.com/cn/actions/learn-github-actions) _(docs.github.com)_
|
127
docs/homebrew.md
Normal file
127
docs/homebrew.md
Normal file
@ -0,0 +1,127 @@
|
||||
Homebrew 备忘清单
|
||||
===
|
||||
|
||||
Homebrew 是 macOS(或Linux)缺少的包管理器,备忘清单包含 [brew](https://github.com/Homebrew/brew) 命令的使用与安装
|
||||
|
||||
Homebrew
|
||||
---
|
||||
|
||||
### 安装
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
```bash
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
加速安装和更新,将仓库源码通过 [gitee](https://gitee.com/) 同步到国内,这样速度杠杠的
|
||||
|
||||
```bash
|
||||
# 把 Homebrew/brew 的 Git 镜像放在这里
|
||||
export HOMEBREW_BREW_GIT_REMOTE="..."
|
||||
# 将 Homebrew/homebrew-core 的 Git 镜像放在这里
|
||||
export HOMEBREW_CORE_GIT_REMOTE="..."
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
在安装期间跳过克隆 (beta)
|
||||
|
||||
```bash
|
||||
export HOMEBREW_INSTALL_FROM_API=1
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 命令
|
||||
|
||||
命令 | 说明
|
||||
:--- :---
|
||||
`brew install git` | `安装`一个包
|
||||
`brew uninstall git` | `删除`/`卸载`软件包
|
||||
`brew upgrade git` | 升级包
|
||||
:--- :---
|
||||
`brew unlink git` | `取消`链接
|
||||
`brew link git` | 关联
|
||||
`brew switch git 2.5.0` | 更改版本
|
||||
:--- :---
|
||||
`brew list --versions git` | 看看你有什么版本
|
||||
:--- :---
|
||||
`brew help` | 打印帮助信息
|
||||
`brew help <sub-command>` | 打印子命令的帮助信息
|
||||
|
||||
### 更多包命令
|
||||
|
||||
命令 | 说明
|
||||
:--- :---
|
||||
`brew info git` | 列出版本、注意事项等
|
||||
`brew cleanup git` | 删除旧版本
|
||||
`brew edit git` | 编辑此软件包
|
||||
`brew cat git` | 打印这个软件包
|
||||
`brew home git` | 打开主页
|
||||
`brew search git` | 搜索公式
|
||||
|
||||
### Brew Cask 命令
|
||||
|
||||
命令 | 说明
|
||||
:--- :---
|
||||
`brew install --cask firefox` | 安装火狐浏览器
|
||||
`brew list --cask` | 列出已安装应用
|
||||
|
||||
Cask 命令用于与图形应用程序交互
|
||||
|
||||
### 全局命令
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
命令 | 说明
|
||||
:--- :---
|
||||
`brew update` | 更新 `brew` 和 `cask`
|
||||
`brew upgrade` | 升级所有软件包
|
||||
`brew list` | 已安装列表
|
||||
`brew outdated` | 升级需要什么?
|
||||
`brew doctor` | 诊断冲泡问题
|
||||
`brew pin <formula>` | 防止指定软件包升级
|
||||
`brew unpin <formula>` | 允许升级指定的软件包
|
||||
|
||||
### Brew 清理
|
||||
|
||||
```bash
|
||||
$ brew cleanup # 删除旧版本的已安装软件包
|
||||
$ brew cleanup <formula> # 删除旧版本指定软件包
|
||||
# 显示所有将被删除的软件包(试运行)
|
||||
$ brew cleanup -n
|
||||
```
|
||||
|
||||
### brew 源码仓库
|
||||
|
||||
```bash
|
||||
# 列出所有当前点击的源码仓库(点击)
|
||||
$ brew tap
|
||||
# 使用 https 从 Github 中点击软件包源码仓库以点击
|
||||
# https://github.com/user/homebrew-repo
|
||||
$ brew tap <user/repo>
|
||||
# 点击指定 URL 中的软件源码仓库
|
||||
$ brew tap <user/repo> <URL>
|
||||
# 从存储库中删除给定的源码仓库
|
||||
$ brew untap <user/repo>
|
||||
```
|
||||
|
||||
### 搜索查看
|
||||
|
||||
```bash
|
||||
# 列出所有已安装的软件包
|
||||
$ brew list
|
||||
# 显示所有本地可用的 brew 配方
|
||||
$ brew search
|
||||
# 对用于 brew 的软件包名称执行子字符串搜索
|
||||
$ brew search <text>
|
||||
# 显示有关软件包的信息
|
||||
$ brew info <formula>
|
||||
```
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
- [Homebrew 官网](https://brew.sh/index_zh-cn) _(brew.sh)_
|
||||
- [Homebrew brew 源码](https://github.com/Homebrew/brew) _(github.com)_
|
||||
- [Homebrew core 源码](https://github.com/Homebrew/homebrew-core) _(github.com)_
|
424
docs/koajs.md
Normal file
424
docs/koajs.md
Normal file
@ -0,0 +1,424 @@
|
||||
Koajs 备忘清单
|
||||
===
|
||||
|
||||
基于 Node.js 平台的下一代 web 开发框架,包含 [Koa](https://koajs.com/) 的 API 参考列表和一些示例。
|
||||
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### Hello World
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
[Koa](https://koajs.com/) 需要 [node v7.6.0](https://nodejs.org) 或更高版本来支持ES2015、异步方法,你可以安装自己支持的 `node` 版本
|
||||
|
||||
- 安装依赖
|
||||
```bash
|
||||
$ mkdir myapp # 创建目录
|
||||
$ cd myapp # 进入目录
|
||||
$ nvm install 7
|
||||
$ npm init -y # 初始化一个配置
|
||||
$ npm install koa # 安装依赖
|
||||
```
|
||||
- 入口文件 `index.js` 添加代码:
|
||||
```js
|
||||
const Koa = require('koa');
|
||||
const app = new Koa();
|
||||
|
||||
app.use(async ctx => {
|
||||
ctx.body = 'Hello World';
|
||||
});
|
||||
|
||||
app.listen(3000);
|
||||
```
|
||||
- 使用以下命令运行应用程序
|
||||
```bash
|
||||
$ node index.js
|
||||
```
|
||||
<!--rehype:className=style-timeline-->
|
||||
|
||||
### 级联
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```js
|
||||
const Koa = require('koa');
|
||||
const app = new Koa();
|
||||
// X-Response-Time x 响应时间
|
||||
app.use(async (ctx, next) => {
|
||||
const start = Date.now();
|
||||
await next();
|
||||
const ms = Date.now() - start;
|
||||
ctx.set('X-Response-Time', `${ms}ms`);
|
||||
});
|
||||
// 记录器 logger
|
||||
app.use(async (ctx, next) => {
|
||||
const start = Date.now();
|
||||
await next();
|
||||
const ms = Date.now() - start;
|
||||
console.log(
|
||||
`${ctx.method} ${ctx.url} - ${ms}`
|
||||
);
|
||||
});
|
||||
// 响应 response
|
||||
app.use(async ctx => {
|
||||
ctx.body = 'Hello World';
|
||||
});
|
||||
app.listen(3000);
|
||||
```
|
||||
|
||||
### 配置
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`app.env` | 默认为 `NODE_ENV` 或 `development`
|
||||
`app.keys` | 签名 `cookie` 密钥数组
|
||||
`app.proxy` | 何时信任真正的代理头字段
|
||||
`app.subdomainOffset` | 要忽略的 `.subdomains` 的偏移量,默认为 `2`
|
||||
`app.proxyIpHeader` | 代理 `ip` 头,默认为 `X-Forwarded-For`
|
||||
`app.maxIpsCount` | 从代理 `ip` 头读取的最大 `ips` 数,默认为 `0`(表示无穷大)
|
||||
<!--rehype:className=style-list style-list-arrow-->
|
||||
|
||||
### app.callback()
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`app.listen(...)` [#](https://koajs.com/#app-listen-) | 为一个绑定 `3000` 端口的简单 `Koa` 应用
|
||||
`app.callback()` [#](https://koajs.com/#app-callback-) | 返回一个适合 `http.createServer()` 方法的回调函数用来处理请求
|
||||
`app.use(function)` [#](https://koajs.com/#app-use-function-) | 添加指定的中间件,详情请看 [Middleware](https://github.com/koajs/koa/wiki#middleware)
|
||||
`app.keys` [#](https://koajs.com/#app-keys-) | 设置签名 `cookie` 密钥
|
||||
`app.context` [#](https://koajs.com/#app-context) | 从中创建 `ctx` 的原型
|
||||
<!--rehype:className=style-list style-list-arrow-->
|
||||
|
||||
### 错误处理
|
||||
|
||||
```js
|
||||
app.on('error', (err, ctx) => {
|
||||
log.error('server error', err, ctx)
|
||||
});
|
||||
```
|
||||
|
||||
默认情况下 `Koa` 会将所有错误信息输出到 `stderr`, 除非 `app.silent` 是 `true`。当 `err.status` 是 `404` 或者 `err.expose` 时,默认错误处理程序也不会输出错误
|
||||
|
||||
### Context 示例
|
||||
|
||||
```js
|
||||
app.use(async ctx => {
|
||||
ctx; // 这是上下文 Context
|
||||
ctx.request; // 这是 koa Request
|
||||
ctx.response; // 这是 koa Response
|
||||
});
|
||||
```
|
||||
|
||||
### app.listen(...)
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
```js
|
||||
const Koa = require('koa');
|
||||
const app = new Koa();
|
||||
app.listen(3000);
|
||||
```
|
||||
|
||||
`app.listen(...)` 实际上是以下代码的语法糖:
|
||||
|
||||
```js
|
||||
const http = require('http');
|
||||
const Koa = require('koa');
|
||||
const app = new Koa();
|
||||
http.createServer(app.callback()).listen(3000);
|
||||
```
|
||||
|
||||
这意味着您可以同时支持 `HTTPS` 和 `HTTPS`,或者在 `多个端口` 监听同一个应用
|
||||
|
||||
```js
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
const Koa = require('koa');
|
||||
const app = new Koa();
|
||||
http.createServer(app.callback()).listen(3000);
|
||||
https.createServer(app.callback()).listen(3001);
|
||||
```
|
||||
|
||||
### ctx.throw 示例
|
||||
|
||||
```js
|
||||
ctx.throw(400);
|
||||
ctx.throw(400, 'name required');
|
||||
ctx.throw(400, 'name required', { user: user });
|
||||
```
|
||||
|
||||
`this.throw('name required', 400)` 等价于
|
||||
|
||||
```js
|
||||
const err = new Error('name required');
|
||||
err.status = 400;
|
||||
err.expose = true;
|
||||
throw err;
|
||||
```
|
||||
|
||||
### ctx.assert 示例
|
||||
|
||||
```js
|
||||
ctx.assert(
|
||||
ctx.state.user,
|
||||
401,
|
||||
'User not found. Please login!'
|
||||
);
|
||||
```
|
||||
|
||||
### Context(上下文) API
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`ctx.req` | Node 的 request 对象
|
||||
`ctx.res` | Node 的 response 对象
|
||||
`ctx.request` | Koa 的 Request 对象
|
||||
`ctx.response` | Koa 的 Response 对象
|
||||
`ctx.state` | 推荐的命名空间,用于通过中间件传递信息到前端视图
|
||||
`ctx.app` | 应用实例引用
|
||||
`ctx.app.emit` | 发出由第一个参数定义的类型的事件
|
||||
`ctx.cookies.get(name, [options])` | 获得 `cookie` 中名为 `name` 的值
|
||||
`ctx.cookies.set(name, value, [options])` | 设置 `cookie` 中名为 `name` 的值
|
||||
`ctx.throw([status], [msg], [properties])` | 抛出包含 `.status` 属性的错误,默认为 `500`
|
||||
`ctx.assert(value, [status], [msg], [properties])` | 当 `!value` 时, `Helper` 方法抛出一个类似 `.throw()` 的错误
|
||||
`ctx.respond` | 避免使用 `Koa` 的内置响应处理功能,您可以直接赋值 `this.repond = false`
|
||||
<!--rehype:className=style-list style-list-arrow-->
|
||||
|
||||
### ctx.cookies.set 参数
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`maxAge` | 表示从Date开始的毫秒数 `now()` 到期。
|
||||
`expires` | 一个 `Date` 对象,指示 `cookie` 的到期日期(默认情况下在会话结束时到期)
|
||||
`path` | 表示 `cookie` 路径的字符串(默认为`/`)
|
||||
`domain` | 表示 `cookie` 的域的字符串(无默认值)
|
||||
`secure` | 一个布尔值,指示 `cookie` 是否只通过HTTPS发送(HTTP默认为false,HTTPS默认为true)。阅读有关此选项的更多信息
|
||||
`httpOnly` | 一个布尔值,指示cookie是否只通过HTTP(S)发送,而不可用于客户端 JavaScript(默认为true)
|
||||
`sameSite` | 一个布尔值或字符串,指示cookie是否为“同一站点”cookie(默认为false)。这可以设置为“strict”、“lax”、“none”或true(映射为“strect”)
|
||||
`signed` | 一个布尔值,指示是否对cookie进行签名(默认为false)。如果这是真的,还将发送另一个附加了.sig后缀的同名cookie,其中一个27字节的url安全base64 SHA1值表示cookie name=cookie值相对于第一个Keygrip键的哈希值。此签名密钥用于在下次收到cookie时检测篡改
|
||||
`overwrite` | 一个布尔值,指示是否覆盖以前设置的同名 `cookie`(默认为false)。如果为true,则在设置此Cookie时,将从set-Cookie标头中筛选出在同一请求期间设置的具有相同名称的所有Cookie(无论路径或域如何)
|
||||
<!--rehype:className=style-list style-list-arrow-->
|
||||
|
||||
### 请求(Request)
|
||||
<!--rehype:wrap-class=row-span-5-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`request.header` | 请求头对象
|
||||
`request.header=` | 设置请求头对象
|
||||
`request.headers` | 请求头对象。等价于 request.header.
|
||||
`request.headers=` | 设置请求头对象。 等价于request.header=.
|
||||
`request.method` | 请求方法
|
||||
`request.method=` | 设置请求方法, 在实现中间件时非常有用,比如 methodOverride()
|
||||
`request.length` | 以数字的形式返回 request 的内容长度(Content-Length),或者返回 undefined。
|
||||
`request.url` | 获得请求url地址.
|
||||
`request.url=` | 设置请求地址,用于重写url地址时
|
||||
`request.originalUrl` | 获取请求原始地址
|
||||
`request.origin` | 获取URL原始地址, 包含 protocol 和 host
|
||||
`request.href` | 获取完整的请求URL, 包含 protocol, host 和 url
|
||||
`request.path` | 获取请求路径名
|
||||
`request.path=` | 设置请求路径名并保留当前查询字符串
|
||||
`request.querystring` | 获取查询参数字符串(url中?后面的部分),不包含?
|
||||
`request.querystring=` | 设置原始查询字符串
|
||||
`request.search` | 获取查询参数字符串,包含?
|
||||
`request.search=` | 设置原始查询字符串
|
||||
`request.host` | 获取 host (hostname:port)。 当 app.proxy 设置为 true 时,支持 X-Forwarded-Host
|
||||
`request.hostname` | 获取 hostname。当 app.proxy 设置为 true 时,支持 X-Forwarded-Host。
|
||||
`request.URL` | 获取 WHATWG 解析的对象.
|
||||
`request.type` | 获取请求 Content-Type,不包含像 "charset" 这样的参数。
|
||||
`request.charset` | 获取请求 charset,没有则返回 `undefined`
|
||||
`request.query` | 将查询参数字符串进行解析并以对象的形式返回,如果没有查询参数字字符串则返回一个空对象
|
||||
`request.query=` | 根据给定的对象设置查询参数字符串
|
||||
`request.fresh` | 检查请求缓存是否 "fresh"(内容没有发生变化)
|
||||
`request.stale` | 与 req.fresh 相反
|
||||
`request.protocol` | 返回请求协议,"https" 或者 "http"
|
||||
`request.secure` | 简化版 this.protocol == "https",用来检查请求是否通过 TLS 发送
|
||||
`request.ip` | 请求远程地址,当 app.proxy 设置为 true 时,支持 X-Forwarded-Host
|
||||
`request.ips` | 当 X-Forwarded-For 存在并且 app.proxy 有效,将会返回一个有序(从 upstream 到 downstream)ip 数组
|
||||
`request.subdomains` | 以数组形式返回子域名
|
||||
`request.is(types...)` | 检查请求所包含的 "Content-Type" 是否为给定的 type 值
|
||||
`request.accepts(types)` | 检查给定的类型 types(s) 是否可被接受,当为 true 时返回最佳匹配,否则返回 false
|
||||
`request.acceptsEncodings(encodings)` | 检查 `encodings` 是否可以被接受,当为 `true` 时返回最佳匹配,否则返回 `false`
|
||||
`request.acceptsCharsets(charsets)` | 检查 `charsets` 是否可以被接受,如果为 `true` 则返回最佳匹配,否则返回 `false`
|
||||
`request.acceptsLanguages(langs)` | 检查 `langs` 是否可以被接受,如果为 `true` 则返回最佳匹配,否则返回 `false`
|
||||
`request.idempotent` | 检查请求是否为幂等(idempotent)
|
||||
`request.socket` | 返回请求的socket
|
||||
`request.get(field)` | 返回请求头
|
||||
<!--rehype:className=style-list style-list-arrow-->
|
||||
|
||||
### 响应(Response)
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`response.header` | Response header 对象
|
||||
`response.headers` | Response header 对象。等价于 response.header.
|
||||
`response.socket` | Request socket.
|
||||
`response.status` | 获取响应状态。 默认情况下,response.status设置为404,而不像node's res.statusCode默认为200。
|
||||
`response.status=` | 通过数字设置响应状态
|
||||
`response.message` | 获取响应状态消息。默认情况下, response.message关联response.status。
|
||||
`response.message=` | 将响应状态消息设置为给定值。
|
||||
`response.length=` | 将响应Content-Length设置为给定值。
|
||||
`response.length` | 如果 Content-Length 作为数值存在,或者可以通过 ctx.body 来进行计算,则返回相应数值,否则返回 undefined。
|
||||
`response.body` | 获取响应体。
|
||||
`response.body=` | 设置响应体为如 `string`,`Buffer`,`Stream`,`Object\|Array`,`null`
|
||||
`response.get(field)` | 获取 response header 中字段值,field 不区分大小写
|
||||
`response.set(field, value)` | 设置 response header 字段 field 的值为 value
|
||||
`response.append(field, value)`| 添加额外的字段field 的值为 val
|
||||
`response.set(fields)` | 使用对象同时设置 response header 中多个字段的值
|
||||
`response.remove(field)` | 移除 response header 中字段 filed
|
||||
`response.type` | 获取 response Content-Type,不包含像"charset"这样的参数
|
||||
`response.type=` | 通过 mime 类型的字符串或者文件扩展名设置 response Content-Type
|
||||
`response.is(types...)` | 跟 `ctx.request.is()` 非常类似。用来检查响应类型是否是所提供的类型之一
|
||||
`response.redirect(url, [alt])` | 执行 [302] 重定向到对应 url
|
||||
`response.attachment([filename])` | 设置 "attachment" 的 Content-Disposition,用于给客户端发送信号来提示下载
|
||||
`response.headerSent` | 检查 response header 是否已经发送,用于在发生错误时检查客户端是否被通知。
|
||||
`response.lastModified` | 如果存在 Last-Modified,则以 Date 的形式返回。
|
||||
`response.lastModified=` | 以 UTC 格式设置 Last-Modified。您可以使用 Date 或 date 字符串来进行设置。
|
||||
`response.etag=` | 设置 包含 "s 的 ETag
|
||||
`response.vary(field)` | 不同于field.
|
||||
`response.flushHeaders()` | 刷新任何设置的响应头,并开始响应体
|
||||
<!--rehype:className=style-list style-list-arrow-->
|
||||
|
||||
### 请求(Request)别名
|
||||
|
||||
以下访问器和别名与 [Request](#请求request) 等价:
|
||||
|
||||
- `ctx.header`
|
||||
- `ctx.headers`
|
||||
- `ctx.method`
|
||||
- `ctx.method=`
|
||||
- `ctx.url`
|
||||
- `ctx.url=`
|
||||
- `ctx.originalUrl`
|
||||
- `ctx.origin`
|
||||
- `ctx.href`
|
||||
- `ctx.path`
|
||||
- `ctx.path=`
|
||||
- `ctx.query`
|
||||
- `ctx.query=`
|
||||
- `ctx.querystring`
|
||||
- `ctx.querystring=`
|
||||
- `ctx.host`
|
||||
- `ctx.hostname`
|
||||
- `ctx.fresh`
|
||||
- `ctx.stale`
|
||||
- `ctx.socket`
|
||||
- `ctx.protocol`
|
||||
- `ctx.secure`
|
||||
- `ctx.ip`
|
||||
- `ctx.ips`
|
||||
- `ctx.subdomains`
|
||||
- `ctx.is()`
|
||||
- `ctx.accepts()`
|
||||
- `ctx.acceptsEncodings()`
|
||||
- `ctx.acceptsCharsets()`
|
||||
- `ctx.acceptsLanguages()`
|
||||
- `ctx.get()`
|
||||
|
||||
### 响应(Response)别名
|
||||
|
||||
以下访问器和别名与 [Response](#响应response) 等价:
|
||||
|
||||
- `ctx.body`
|
||||
- `ctx.body=`
|
||||
- `ctx.status`
|
||||
- `ctx.status=`
|
||||
- `ctx.message`
|
||||
- `ctx.message=`
|
||||
- `ctx.length=`
|
||||
- `ctx.length`
|
||||
- `ctx.type=`
|
||||
- `ctx.type`
|
||||
- `ctx.headerSent`
|
||||
- `ctx.redirect()`
|
||||
- `ctx.attachment()`
|
||||
- `ctx.set()`
|
||||
- `ctx.append()`
|
||||
- `ctx.remove()`
|
||||
- `ctx.lastModified=`
|
||||
- `ctx.etag=`
|
||||
|
||||
### request.fresh 示例
|
||||
|
||||
```js
|
||||
// freshness 检查需要状态 20x 或 304
|
||||
ctx.status = 200;
|
||||
ctx.set('ETag', '123');
|
||||
|
||||
// 缓存正常
|
||||
if (ctx.fresh) {
|
||||
ctx.status = 304;
|
||||
return;
|
||||
}
|
||||
|
||||
// 缓存已过时
|
||||
// 获取新数据
|
||||
ctx.body = await db.find('something');
|
||||
```
|
||||
|
||||
### ctx.is 示例
|
||||
|
||||
```js
|
||||
// Content-Type: text/html; charset=utf-8
|
||||
ctx.is('html'); // => 'html'
|
||||
ctx.is('text/html'); // => 'text/html'
|
||||
ctx.is('text/*', 'text/html');
|
||||
// => 'text/html'
|
||||
// 当 Content-Type 为 application/json 时
|
||||
ctx.is('json', 'urlencoded'); // => 'json'
|
||||
ctx.is('application/json');
|
||||
// => 'application/json'
|
||||
ctx.is('html', 'application/*');
|
||||
// => 'application/json'
|
||||
|
||||
ctx.is('html'); // => false
|
||||
```
|
||||
|
||||
### ctx.accepts 示例
|
||||
|
||||
```js
|
||||
// 接受: text/*, application/json
|
||||
ctx.accepts('html');
|
||||
// => "html"
|
||||
ctx.accepts('text/html');
|
||||
// => "text/html"
|
||||
ctx.accepts('json', 'text');
|
||||
// => "json"
|
||||
ctx.accepts('application/json');
|
||||
// => "application/json"
|
||||
```
|
||||
|
||||
### request.acceptsCharsets 示例
|
||||
|
||||
```js
|
||||
// Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5
|
||||
ctx.acceptsCharsets('utf-8', 'utf-7');
|
||||
// => "utf-8"
|
||||
|
||||
ctx.acceptsCharsets(['utf-7', 'utf-8']);
|
||||
// => "utf-8"
|
||||
```
|
||||
|
||||
检查 `charsets` 是否可以被接受,如果为 `true` 则返回最佳匹配, 否则返回 `false`
|
||||
|
||||
### response.set 示例
|
||||
|
||||
```js
|
||||
ctx.set({
|
||||
'Etag': '1234',
|
||||
'Last-Modified': date
|
||||
});
|
||||
```
|
||||
|
||||
使用对象同时设置 response header 中多个字段的值
|
||||
|
||||
### response.type 示例
|
||||
|
||||
```js
|
||||
const ct = ctx.type;
|
||||
// => "image/png"
|
||||
```
|
||||
|
||||
获取 response Content-Type,不包含像"charset"这样的参数
|
719
docs/lessjs.md
Normal file
719
docs/lessjs.md
Normal file
@ -0,0 +1,719 @@
|
||||
Less 备忘清单
|
||||
===
|
||||
|
||||
本备忘单旨在快速理解 [Less](https://github.com/less/less.js) 所涉及的主要概念,显示了它的常用方法使用清单。
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### 介绍
|
||||
|
||||
Less(Leaner Style Sheets 的缩写)是一门向后兼容的 [`CSS`](./css.md) 扩展语言
|
||||
|
||||
- [CSS 备忘清单](./css.md) _(jaywcjlove.github.io)_
|
||||
- [在线编译预览](http://lesscss.org/less-preview/#eyJjb2RlIjoiI2xpYigpIHtcbiAgICAuY29sb3JzKCkge1xuICAgICAgQHByaW1hcnk6IGJsdWU7XG4gICAgICBAc2Vjb25kYXJ5OiBncmVlbjtcbiAgICB9XG4gICAgLnJ1bGVzKEBzaXplKSB7XG4gICAgICBib3JkZXI6IEBzaXplIHNvbGlkIHdoaXRlO1xuICAgIH1cbiAgfVxuICBcbiAgLmJveCB3aGVuICgjbGliLmNvbG9yc1tAcHJpbWFyeV0gPSBibHVlKSB7XG4gICAgd2lkdGg6IDEwMHB4O1xuICAgIGhlaWdodDogKCR3aWR0aCAvIDIpO1xuICB9XG4gIFxuICAuYmFyOmV4dGVuZCguYm94KSB7XG4gICAgQG1lZGlhIChtaW4td2lkdGg6IDYwMHB4KSB7XG4gICAgICB3aWR0aDogMjAwcHg7XG4gICAgICAjbGliLnJ1bGVzKDFweCk7XG4gICAgfVxuICB9IiwiYWN0aXZlVmVyc2lvbiI6IjQueCJ9) _(lesscss.org)_
|
||||
|
||||
在 Node.js 环境中使用 `Less`
|
||||
|
||||
```bash
|
||||
$ npm install -g less
|
||||
$ lessc styles.less styles.css
|
||||
```
|
||||
|
||||
在浏览器环境中使用 `Less`
|
||||
|
||||
```html
|
||||
<link rel="stylesheet/less" type="text/css" href="styles.less" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/less@4" ></script>
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 变量(Variables)
|
||||
|
||||
```less
|
||||
@width: 10px;
|
||||
@height: @width + 10px;
|
||||
|
||||
#header {
|
||||
width: @width;
|
||||
height: @height;
|
||||
}
|
||||
```
|
||||
|
||||
编译 css 为:
|
||||
|
||||
```css
|
||||
#header {
|
||||
width: 10px;
|
||||
height: 20px;
|
||||
}
|
||||
```
|
||||
|
||||
另见: [变量的更多信息](https://lesscss.org/features/#variables-feature)
|
||||
|
||||
### 混合(Mixins)
|
||||
|
||||
```less {1,8,13}
|
||||
.bordered {
|
||||
border-top: dotted 1px black;
|
||||
border-bottom: solid 2px black;
|
||||
}
|
||||
|
||||
#menu a {
|
||||
color: #111;
|
||||
.bordered();
|
||||
}
|
||||
|
||||
.post a {
|
||||
color: red;
|
||||
.bordered();
|
||||
}
|
||||
```
|
||||
|
||||
另见: [混合(Mixin)的更多信息](https://lesscss.org/features/#mixins-feature)
|
||||
|
||||
|
||||
### 嵌套(Nesting)
|
||||
|
||||
```css
|
||||
#header {
|
||||
color: black;
|
||||
}
|
||||
#header .navigation {
|
||||
font-size: 12px;
|
||||
}
|
||||
#header .logo {
|
||||
width: 300px;
|
||||
}
|
||||
```
|
||||
|
||||
👇👇 更改为 less 的写法 ✅ 👇👇
|
||||
|
||||
```less
|
||||
#header {
|
||||
color: black;
|
||||
.navigation {
|
||||
font-size: 12px;
|
||||
}
|
||||
.logo {
|
||||
width: 300px;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 父选择器 &
|
||||
|
||||
```less
|
||||
.button {
|
||||
color: blue;
|
||||
&-ok {
|
||||
background-image: url("ok.png");
|
||||
}
|
||||
&:hover {
|
||||
color: green;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
编译 css 为:
|
||||
|
||||
```css
|
||||
.button {
|
||||
color: blue;
|
||||
}
|
||||
.button-ok {
|
||||
background-image: url("ok.png");
|
||||
}
|
||||
.button:hover {
|
||||
color: green;
|
||||
}
|
||||
```
|
||||
|
||||
### @规则嵌套和冒泡
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```less
|
||||
.component {
|
||||
width: 300px;
|
||||
@media (min-width: 768px) {
|
||||
width: 600px;
|
||||
@media (min-resolution: 192dpi) {
|
||||
background-image: url(/img/icon2x.png);
|
||||
}
|
||||
}
|
||||
@media (min-width: 1280px) {
|
||||
width: 800px;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
编译 css 为:
|
||||
|
||||
```css
|
||||
.component {
|
||||
width: 300px;
|
||||
}
|
||||
@media (min-width: 768px) {
|
||||
.component {
|
||||
width: 600px;
|
||||
}
|
||||
}
|
||||
@media (min-width: 768px) and (min-resolution: 192dpi) {
|
||||
.component {
|
||||
background-image: url(/img/icon2x.png);
|
||||
}
|
||||
}
|
||||
@media (min-width: 1280px) {
|
||||
.component {
|
||||
width: 800px;
|
||||
}
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 运算(Operations)
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
算术运算符 `+`、`-`、`*`、`/` 对任何数字、颜色或变量进行运算
|
||||
|
||||
```less
|
||||
@conversion-1: 5cm + 10mm; // 结果是 6cm
|
||||
@conversion-2: 2 - 3cm - 5mm; // 结果 -1.5cm
|
||||
@incompatible-units: 2 + 5px - 3cm;
|
||||
// 结果是 4px
|
||||
@base: 5%;
|
||||
@filler: @base * 2; // 结果是 10%
|
||||
@other: @base + @filler; // 结果是 15%
|
||||
|
||||
@base: 2cm * 3mm; // 结果是 6cm
|
||||
@color: (#224488 / 2); // 结果是 #112244
|
||||
background-color: #112244 + #111;
|
||||
// 结果是 #223355
|
||||
@color: #222 / 2;
|
||||
// 结果是 `#222 / 2`, not #111
|
||||
background-color: (#FFFFFF / 16);
|
||||
// 结果是 #101010
|
||||
```
|
||||
|
||||
#### calc() 特例
|
||||
|
||||
为了与 `CSS` 保持兼容,`calc()` 并不对数学表达式进行计算,但是在嵌套函数中会计算变量和数学公式的值
|
||||
|
||||
```less
|
||||
@var: 50vh/2;
|
||||
width: calc(50% + (@var - 20px));
|
||||
// 结果是 calc(50% + (25vh - 20px))
|
||||
```
|
||||
|
||||
### 转义(Escaping)
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```less
|
||||
@min768: ~"(min-width: 768px)";
|
||||
.element {
|
||||
@media @min768 {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
编译 css 为:
|
||||
|
||||
```css
|
||||
@media (min-width: 768px) {
|
||||
.element {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
从 Less 3.5 开始,可以简写为
|
||||
|
||||
```less
|
||||
@min768: (min-width: 768px);
|
||||
.element {
|
||||
@media @min768 {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
在 Less 3.5+ 版本中,许多以前需要“引号转义”的情况就不再需要了
|
||||
|
||||
### 函数(Functions)
|
||||
|
||||
```less
|
||||
@base: #f04615;
|
||||
@width: 0.5;
|
||||
|
||||
.class {
|
||||
width: percentage(@width); // 返回 `50%`
|
||||
color: saturate(@base, 5%);
|
||||
background-color:
|
||||
spin(lighten(@base, 25%), 8);
|
||||
}
|
||||
```
|
||||
|
||||
Less 内置了多种函数用于转换颜色、处理字符串、算术运算等
|
||||
|
||||
### 命名空间和访问符
|
||||
|
||||
```less
|
||||
#bundle() {
|
||||
.button {
|
||||
display: block;
|
||||
border: 1px solid black;
|
||||
background-color: grey;
|
||||
&:hover {
|
||||
background-color: white;
|
||||
}
|
||||
}
|
||||
.tab { ... }
|
||||
.citation { ... }
|
||||
}
|
||||
```
|
||||
|
||||
把 `.button` 类混合到 `#header a` 中,我们可以这样做
|
||||
|
||||
```less
|
||||
#header a {
|
||||
color: orange;
|
||||
#bundle.button();
|
||||
// 还可以书写为 #bundle > .button 形式
|
||||
}
|
||||
```
|
||||
|
||||
### 映射(Maps)
|
||||
|
||||
```less
|
||||
#colors() {
|
||||
primary: blue;
|
||||
secondary: green;
|
||||
}
|
||||
|
||||
.button {
|
||||
color: #colors[primary];
|
||||
border: 1px solid #colors[secondary];
|
||||
}
|
||||
```
|
||||
|
||||
输出符合预期(css):
|
||||
|
||||
```css
|
||||
.button {
|
||||
color: blue;
|
||||
border: 1px solid green;
|
||||
}
|
||||
```
|
||||
|
||||
另见:[映射(Maps)](https://lesscss.org/features/#maps-feature)
|
||||
|
||||
### 作用域(Scope)
|
||||
|
||||
```less
|
||||
@var: red;
|
||||
|
||||
#page {
|
||||
@var: white;
|
||||
#header {
|
||||
color: @var; // white
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
和上面实例代码相同
|
||||
|
||||
```less
|
||||
@var: red;
|
||||
|
||||
#page {
|
||||
#header {
|
||||
color: @var; // white
|
||||
}
|
||||
@var: white;
|
||||
}
|
||||
```
|
||||
|
||||
另见:[懒加载](https://lesscss.org/features/#variables-feature-lazy-loading)
|
||||
|
||||
### 注释(Comments)
|
||||
|
||||
```less
|
||||
/* 一个块注释
|
||||
* style comment! */
|
||||
@var: red;
|
||||
|
||||
// 这一行被注释掉了!
|
||||
@var: white;
|
||||
```
|
||||
|
||||
块注释和行注释都可以使用
|
||||
|
||||
### 导入(Importing)
|
||||
|
||||
```less
|
||||
@import "library"; // library.less
|
||||
@import "typo.css";
|
||||
```
|
||||
|
||||
另见:[导入(Importing)的知识](https://lesscss.org/features/#imports-feature)
|
||||
|
||||
### Extend
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```less
|
||||
nav ul {
|
||||
&:extend(.inline);
|
||||
background: blue;
|
||||
}
|
||||
.inline {
|
||||
color: red;
|
||||
}
|
||||
```
|
||||
|
||||
编译 css 为:
|
||||
|
||||
```css
|
||||
nav ul {
|
||||
background: blue;
|
||||
}
|
||||
.inline,
|
||||
nav ul {
|
||||
color: red;
|
||||
}
|
||||
```
|
||||
|
||||
函数
|
||||
---
|
||||
|
||||
### 逻辑函数 if & boolean
|
||||
|
||||
```less
|
||||
@bg: black;
|
||||
@bg-light: boolean(luma(@bg) > 50%);
|
||||
|
||||
div {
|
||||
background: @bg;
|
||||
color: if(@bg-light, black, white);
|
||||
}
|
||||
```
|
||||
|
||||
编译 css 为:
|
||||
|
||||
```css
|
||||
div {
|
||||
background: black;
|
||||
color: white;
|
||||
}
|
||||
```
|
||||
|
||||
### 字符串函数
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`escape` | 将 [URL 编码](http://en.wikipedia.org/wiki/Percent-encoding)应用于输入字符串中的特殊字符
|
||||
`e` | 字符串转义
|
||||
`%` | 第一个参数是带有占位符的字符串
|
||||
|
||||
```less
|
||||
escape('a=1') // 输出 a%3D1
|
||||
|
||||
@mscode: "ms:alwaysHasItsOwnSyntax.For.Stuff()"
|
||||
filter: e(@mscode);
|
||||
// 输出 filter: ms:alwaysHasItsOwnSyntax.For.Stuff();
|
||||
|
||||
format-a-d: %("repetitions: %a file: %d", 1 + 2, "directory/file.less");
|
||||
// 输出 format-a-d: "repetitions: 3 file: "directory/file.less"";
|
||||
```
|
||||
|
||||
### 替换字符串 replace
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```less
|
||||
replace("Hello, Mars?", "Mars\?", "Earth!");
|
||||
replace("One + one = 4", "one", "2", "gi");
|
||||
replace('This is a string.', "(string)\.$", "new $1.");
|
||||
replace(~"bar-1", '1', '2');
|
||||
```
|
||||
|
||||
预期输出
|
||||
|
||||
```
|
||||
"Hello, Earth!";
|
||||
"2 + 2 = 4";
|
||||
'This is a new string.';
|
||||
bar-2;
|
||||
```
|
||||
|
||||
### length
|
||||
|
||||
```less
|
||||
@list: "banana", "tomato", "potato", "peach";
|
||||
n: length(@list);
|
||||
```
|
||||
|
||||
预期输出
|
||||
|
||||
```css
|
||||
n: 4;
|
||||
```
|
||||
|
||||
返回值列表中的元素数
|
||||
|
||||
### extract
|
||||
|
||||
```less
|
||||
@list: apple, pear, coconut, orange;
|
||||
value: extract(@list, 3);
|
||||
```
|
||||
|
||||
预期输出
|
||||
|
||||
```css
|
||||
value: coconut;
|
||||
```
|
||||
|
||||
返回列表中指定位置的值
|
||||
|
||||
### range
|
||||
|
||||
```less
|
||||
value: range(4);
|
||||
// 输出 value: 1 2 3 4;
|
||||
value: range(10px, 30px, 10);
|
||||
// 输出 value: 10px 20px 30px;
|
||||
```
|
||||
|
||||
生成跨越一系列值的列表
|
||||
|
||||
### each
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
```less
|
||||
@selectors: blue, green, red;
|
||||
|
||||
each(@selectors, {
|
||||
.sel-@{value} {
|
||||
a: b;
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
预期输出
|
||||
|
||||
```css
|
||||
.sel-blue {
|
||||
a: b;
|
||||
}
|
||||
.sel-green {
|
||||
a: b;
|
||||
}
|
||||
.sel-red {
|
||||
a: b;
|
||||
}
|
||||
```
|
||||
|
||||
每个列表成员的每个规则集都绑定到 `@value`、`@key` 和 `@index` 变量
|
||||
|
||||
```less
|
||||
@set: {
|
||||
one: blue;
|
||||
two: green;
|
||||
three: red;
|
||||
}
|
||||
.set {
|
||||
each(@set, {
|
||||
@{key}-@{index}: @value;
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
预期输出
|
||||
|
||||
```css
|
||||
.set {
|
||||
one-1: blue;
|
||||
two-2: green;
|
||||
three-3: red;
|
||||
}
|
||||
```
|
||||
|
||||
将规则集的评估绑定到列表的每个成员
|
||||
|
||||
### each()
|
||||
|
||||
```less
|
||||
set-2() {
|
||||
one: blue;
|
||||
two: green;
|
||||
three: red;
|
||||
}
|
||||
.set-2 {
|
||||
// 调用 mixin 并迭代每个规则
|
||||
each(.set-2(), .(@v, @k, @i) {
|
||||
@{k}-@{i}: @v;
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
预期输出
|
||||
|
||||
```css
|
||||
.set-2 {
|
||||
one-1: blue;
|
||||
two-2: green;
|
||||
three-3: red;
|
||||
}
|
||||
```
|
||||
|
||||
### 使用 `range` 和 `each` 创建一个 `for` 循环
|
||||
|
||||
```less
|
||||
each(range(4), {
|
||||
.col-@{value} {
|
||||
height: (@value * 50px);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
预期输出
|
||||
|
||||
```css
|
||||
.col-1 {
|
||||
height: 50px;
|
||||
}
|
||||
.col-2 {
|
||||
height: 100px;
|
||||
}
|
||||
.col-3 {
|
||||
height: 150px;
|
||||
}
|
||||
.col-4 {
|
||||
height: 200px;
|
||||
}
|
||||
```
|
||||
|
||||
### 数学函数
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`ceil(2.4)` _(输出 3)_ | 向上舍入到下一个最大整数 [#](https://lesscss.org/functions/#math-functions-ceil)
|
||||
`floor(2.6)` _(输出 2)_ | 向下舍入到下一个最小整数 [#](https://lesscss.org/functions/#math-functions-floor)
|
||||
`percentage(0.5)` _(输出 50%)_ | 将浮点数转换为百分比字符串 [#](https://lesscss.org/functions/#math-functions-floor)
|
||||
`round(1.67)` _(输出 2)_ | 应用舍入 [#](https://lesscss.org/functions/#math-functions-round)
|
||||
`sqrt(25cm)` _(输出 5cm)_ | 计算数字的平方根。保持单位不变 [#](https://lesscss.org/functions/#math-functions-sqrt)
|
||||
`abs(25cm)` _(输出 25cm)_ | 计算数字的绝对值。 保持单位不变 [#](https://lesscss.org/functions/#math-functions-abs)
|
||||
`sin(1deg)` _(输出 0.01745240643728351)_ | 计算正弦函数 [#](https://lesscss.org/functions/#math-functions-sin)
|
||||
`asin(-0.8414709848078965)` _(输出 -1rad)_ | 计算反正弦(正弦的倒数)函数 [#](https://lesscss.org/functions/#math-functions-asin)
|
||||
`cos(1deg)` _(输出 0.9998476951563913)_ | 计算余弦函数 [#](https://lesscss.org/functions/#math-functions-cos)
|
||||
`acos(0.5403023058681398)` _(输出 1rad)_ | 计算反余弦(余弦的倒数)函数 [#](https://lesscss.org/functions/#math-functions-acos)
|
||||
`tan(1deg)` _(输出 0.017455064928217585)_ | 计算正切函数 [#](https://lesscss.org/functions/#math-functions-tan)
|
||||
`atan(-1.5574077246549023)` _(输出 -1rad)_ | 计算反正切(正切的倒数)函数 [#](https://lesscss.org/functions/#math-functions-atan)
|
||||
`pi()` _(输出 3.141592653589793)_ | π (pi) [#](https://lesscss.org/functions/#math-functions-pi)
|
||||
`pow(0cm, 0px)` _(输出 1cm)_ | 返回第一个参数的第二个参数次幂的值 [#](https://lesscss.org/functions/#math-functions-pow)
|
||||
`mod(11cm, 6px)` _(输出 5cm)_ | 返回第一个参数模数第二个参数的值 [#](https://lesscss.org/functions/#math-functions-mod)
|
||||
`min(5, 10)` _(输出 5)_ | 返回一个或多个值中的最小值 [#](https://lesscss.org/functions/#math-functions-min)
|
||||
`max(5, 10)` _(输出 10)_ | 返回一个或多个值中的最大值 [#](https://lesscss.org/functions/#math-functions-min)
|
||||
<!--rehype:className=style-list-arrow-->
|
||||
|
||||
### 颜色定义函数
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`rgb`| [#](https://lesscss.org/functions/#color-definition-rgb)
|
||||
`rgba`| [#](https://lesscss.org/functions/#color-definition-rgba)
|
||||
`argb`| [#](https://lesscss.org/functions/#color-definition-argb)
|
||||
`hsl`| [#](https://lesscss.org/functions/#color-definition-hsl)
|
||||
`hsla`| [#](https://lesscss.org/functions/#color-definition-hsla)
|
||||
`hsv`| [#](https://lesscss.org/functions/#color-definition-hsv)
|
||||
`hsva`| [#](https://lesscss.org/functions/#color-definition-hsva)
|
||||
|
||||
### 类型函数
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`isnumber`| 值是否为数字 [#](https://lesscss.org/functions/#type-functions-isnumber)
|
||||
`isstring`| 值是否为字符串 [#](https://lesscss.org/functions/#type-functions-isstring)
|
||||
`iscolor`| 值是否为颜色值 [#](https://lesscss.org/functions/#type-functions-iscolor)
|
||||
`iskeyword`| 值是否为 keyword [#](https://lesscss.org/functions/#type-functions-iskeyword)
|
||||
`isurl`| 值是否为 url 值 [#](https://lesscss.org/functions/#type-functions-isurl)
|
||||
`ispixel`| 值是否为像素值 [#](https://lesscss.org/functions/#type-functions-ispixel)
|
||||
`isem`| 值是否为 em 值 [#](https://lesscss.org/functions/#type-functions-isem)
|
||||
`ispercentage`| 值是否为 百分百 值 [#](https://lesscss.org/functions/#type-functions-ispercentage)
|
||||
`isunit`| 值是是否为指定单位的数字 [#](https://lesscss.org/functions/#type-functions-isunit)
|
||||
`isruleset`| 值是否为规则集 [#](https://lesscss.org/functions/#type-functions-isruleset)
|
||||
`isdefined`| 值是否为 defined [#](https://lesscss.org/functions/#type-functions-isdefined)
|
||||
|
||||
### 杂项函数
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`color`| [#](https://lesscss.org/functions/#misc-functions-color)
|
||||
`image-size`| [#](https://lesscss.org/functions/#misc-functions-image-size)
|
||||
`image-width`| [#](https://lesscss.org/functions/#misc-functions-image-width)
|
||||
`image-height`| [#](https://lesscss.org/functions/#misc-functions-image-height)
|
||||
`convert`| [#](https://lesscss.org/functions/#misc-functions-convert)
|
||||
`data-uri`| [#](https://lesscss.org/functions/#misc-functions-data-uri)
|
||||
`default`| [#](https://lesscss.org/functions/#misc-functions-default)
|
||||
`unit`| [#](https://lesscss.org/functions/#misc-functions-unit)
|
||||
`get-unit`| [#](https://lesscss.org/functions/#misc-functions-get-unit)
|
||||
`svg-gradient`| [#](https://lesscss.org/functions/#misc-functions-svg-gradient)
|
||||
|
||||
### 颜色通道函数
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`hue`| [#](https://lesscss.org/functions/#color-channel-hue)
|
||||
`saturation`| [#](https://lesscss.org/functions/#color-channel-saturation)
|
||||
`lightness`| [#](https://lesscss.org/functions/#color-channel-lightness)
|
||||
`hsvhue`| [#](https://lesscss.org/functions/#color-channel-hsvhue)
|
||||
`hsvsaturation`| [#](https://lesscss.org/functions/#color-channel-hsvsaturation)
|
||||
`hsvvalue`| [#](https://lesscss.org/functions/#color-channel-hsvvalue)
|
||||
`red`| [#](https://lesscss.org/functions/#color-channel-red)
|
||||
`green`| [#](https://lesscss.org/functions/#color-channel-green)
|
||||
`blue`| [#](https://lesscss.org/functions/#color-channel-blue)
|
||||
`alpha`| [#](https://lesscss.org/functions/#color-channel-alpha)
|
||||
`luma`| [#](https://lesscss.org/functions/#color-channel-luma)
|
||||
`luminance`| [#](https://lesscss.org/functions/#color-channel-luminance)
|
||||
|
||||
### 色彩运算函数
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`saturate`| [#](https://lesscss.org/functions/#color-operations-saturate)
|
||||
`desaturate`| [#](https://lesscss.org/functions/#color-operations-desaturate)
|
||||
`lighten`| [#](https://lesscss.org/functions/#color-operations-lighten)
|
||||
`darken`| [#](https://lesscss.org/functions/#color-operations-darken)
|
||||
`fadein`| [#](https://lesscss.org/functions/#color-operations-fadein)
|
||||
`fadeout`| [#](https://lesscss.org/functions/#color-operations-fadeout)
|
||||
`fade`| [#](https://lesscss.org/functions/#color-operations-fade)
|
||||
`spin`| [#](https://lesscss.org/functions/#color-operations-spin)
|
||||
`mix`| [#](https://lesscss.org/functions/#color-operations-mix)
|
||||
`tint`| [#](https://lesscss.org/functions/#color-operations-tint)
|
||||
`shade`| [#](https://lesscss.org/functions/#color-operations-shade)
|
||||
`greyscale`| [#](https://lesscss.org/functions/#color-operations-greyscale)
|
||||
`contrast`| [#](https://lesscss.org/functions/#color-operations-contrast)
|
||||
|
||||
### 颜色混合功能
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`multiply`| [#](https://lesscss.org/functions/#color-blending-multiply)
|
||||
`screen`| [#](https://lesscss.org/functions/#color-blending-screen)
|
||||
`overlay`| [#](https://lesscss.org/functions/#color-blending-overlay)
|
||||
`softlight`| [#](https://lesscss.org/functions/#color-blending-softlight)
|
||||
`hardlight`| [#](https://lesscss.org/functions/#color-blending-hardlight)
|
||||
`difference`| [#](https://lesscss.org/functions/#color-blending-difference)
|
||||
`exclusion`| [#](https://lesscss.org/functions/#color-blending-exclusion)
|
||||
`average`| [#](https://lesscss.org/functions/#color-blending-average)
|
||||
`negation`| [#](https://lesscss.org/functions/#color-blending-negation)
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
- [Less.js 官网](http://lesscss.org) _(lesscss.org)_
|
||||
- [CSS 备忘清单](./css.md) _(jaywcjlove.github.io)_
|
||||
- [Stylus 备忘清单](./stylus.md) _(jaywcjlove.github.io)_
|
||||
- [在线编译预览](http://lesscss.org/less-preview/#eyJjb2RlIjoiI2xpYigpIHtcbiAgICAuY29sb3JzKCkge1xuICAgICAgQHByaW1hcnk6IGJsdWU7XG4gICAgICBAc2Vjb25kYXJ5OiBncmVlbjtcbiAgICB9XG4gICAgLnJ1bGVzKEBzaXplKSB7XG4gICAgICBib3JkZXI6IEBzaXplIHNvbGlkIHdoaXRlO1xuICAgIH1cbiAgfVxuICBcbiAgLmJveCB3aGVuICgjbGliLmNvbG9yc1tAcHJpbWFyeV0gPSBibHVlKSB7XG4gICAgd2lkdGg6IDEwMHB4O1xuICAgIGhlaWdodDogKCR3aWR0aCAvIDIpO1xuICB9XG4gIFxuICAuYmFyOmV4dGVuZCguYm94KSB7XG4gICAgQG1lZGlhIChtaW4td2lkdGg6IDYwMHB4KSB7XG4gICAgICB3aWR0aDogMjAwcHg7XG4gICAgICAjbGliLnJ1bGVzKDFweCk7XG4gICAgfVxuICB9IiwiYWN0aXZlVmVyc2lvbiI6IjQueCJ9) _(lesscss.org)_
|
557
docs/stylus.md
Normal file
557
docs/stylus.md
Normal file
@ -0,0 +1,557 @@
|
||||
Stylus 备忘清单
|
||||
===
|
||||
|
||||
本备忘单旨在快速理解 [stylus](https://github.com/stylus/stylus) 所涉及的主要概念,显示了它的常用方法使用清单。
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### 介绍
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
为 Node.js 构建的富有表现力、健壮、功能丰富的 [CSS](./css.md) 语言
|
||||
|
||||
- [CSS 备忘清单](./css.md) _(jaywcjlove.github.io)_
|
||||
- [在线编译预览](https://stylus-lang.com/try.html) _(stylus-lang.com)_
|
||||
|
||||
```bash
|
||||
# npm
|
||||
$ npm install stylus -g
|
||||
# pnpm
|
||||
$ pnpm add -g stylus
|
||||
```
|
||||
|
||||
在 Node.js 环境中使用 `stylus`
|
||||
|
||||
```bash
|
||||
$ stylus one.styl two.styl
|
||||
# stylus 从标准输入读取并输出到标准输出
|
||||
$ stylus --compress < some.styl > some.css
|
||||
# 将 css 目录中的文件编译输出到 `public/css`
|
||||
$ stylus css --out public/css
|
||||
```
|
||||
|
||||
转换 CSS,输出 `*.styl` 文件
|
||||
|
||||
```
|
||||
$ stylus --css < test.css > test.styl
|
||||
$ stylus --css test.css /tmp/out.styl
|
||||
```
|
||||
|
||||
### 支持 CSS 嵌套语法
|
||||
|
||||
```stylus
|
||||
.box {
|
||||
color: blue;
|
||||
.button {
|
||||
color: red;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Stylus 是一个 CSS 预处理器。另见: [stylus-lang.com](http://stylus-lang.com/)
|
||||
|
||||
### 支持类 python 缩进语法
|
||||
|
||||
```stylus
|
||||
.box
|
||||
color: blue
|
||||
.button
|
||||
color: red
|
||||
```
|
||||
|
||||
也有效!冒号也是可选的。这通常用于 Stylus 文档的语法
|
||||
|
||||
### 混合 Mixins
|
||||
|
||||
```stylus
|
||||
caps-type()
|
||||
letter-spacing: 0.05em
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus {2}
|
||||
h5
|
||||
caps-type()
|
||||
```
|
||||
|
||||
编译 css 为:
|
||||
|
||||
```css
|
||||
h5 {
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
```
|
||||
|
||||
另见:下面[Mixins](#混合-Mixins)
|
||||
|
||||
### 变量 Variables
|
||||
|
||||
```stylus
|
||||
royal-blue = #36a
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus
|
||||
div
|
||||
color: royal-blue
|
||||
```
|
||||
|
||||
标识符(变量名、函数等)也可以包括 `$` 字符
|
||||
|
||||
```stylus
|
||||
$font-size = 14px
|
||||
body {
|
||||
font: $font-size sans-serif;
|
||||
}
|
||||
```
|
||||
|
||||
另见:[变量 Variables](https://stylus-lang.com/docs/variables.html)
|
||||
|
||||
混合 Mixins
|
||||
------
|
||||
|
||||
### 没有参数
|
||||
|
||||
```stylus {1}
|
||||
red-border()
|
||||
border: solid 2px red
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus {2}
|
||||
div
|
||||
red-border()
|
||||
```
|
||||
|
||||
另见: [Mixins](http://stylus-lang.com/docs/mixins.html)
|
||||
|
||||
### 有参数
|
||||
|
||||
```stylus {1}
|
||||
border-radius(n)
|
||||
-webkit-border-radius: n
|
||||
border-radius: n
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus {2,3}
|
||||
div
|
||||
border-radius: 2px
|
||||
border-radius(2px)
|
||||
```
|
||||
|
||||
Mixins can be applied in two different ways.
|
||||
|
||||
### 参数默认值
|
||||
|
||||
```stylus {1}
|
||||
border-radius(n = 2px)
|
||||
-webkit-border-radius: n
|
||||
```
|
||||
|
||||
### 块混合
|
||||
|
||||
```stylus {3}
|
||||
mobile()
|
||||
@media (max-width: 480px)
|
||||
{block}
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus {1}
|
||||
+mobile()
|
||||
width: 10px
|
||||
```
|
||||
|
||||
另见: [块混合](http://stylus-lang.com/docs/mixins.html#block-mixins)
|
||||
|
||||
### Rest 参数
|
||||
|
||||
```stylus {1}
|
||||
shadow(offset-x, args...)
|
||||
box-shadow: offset-x args
|
||||
margin-top: offset-x
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus
|
||||
#login
|
||||
shadow: 1px 2px 5px #eee
|
||||
```
|
||||
|
||||
另见: [Rest 参数](http://stylus-lang.com/docs/vargs.html)
|
||||
|
||||
函数 Functions
|
||||
---------
|
||||
|
||||
### 函数 Functions
|
||||
|
||||
```stylus {1}
|
||||
add(a, b)
|
||||
a + b
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus {2}
|
||||
body
|
||||
padding: add(10px, 5)
|
||||
```
|
||||
|
||||
另见: [Functions](http://stylus-lang.com/docs/functions.html)
|
||||
|
||||
### 参数默认值
|
||||
|
||||
```stylus {1}
|
||||
add(a, b = 2)
|
||||
a + b
|
||||
```
|
||||
|
||||
另见: [参数默认值](http://stylus-lang.com/docs/functions.html#argument-defaults)
|
||||
|
||||
### 命名参数
|
||||
|
||||
```stylus
|
||||
shadow(x, y)
|
||||
x y (y * 1.5) #000
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus {2}
|
||||
.button
|
||||
box-shadow: shadow(x: 2, y: 4)
|
||||
```
|
||||
|
||||
另见: [命名参数](http://stylus-lang.com/docs/functions.html#named-parameters)
|
||||
|
||||
### 多个返回值
|
||||
|
||||
```stylus {2}
|
||||
sizes()
|
||||
8px 16px
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus
|
||||
sizes()[0] // → 8px
|
||||
sizes()[1] // → 16px
|
||||
```
|
||||
|
||||
另见: [多个返回值](http://stylus-lang.com/docs/functions.html#multiple-return-values)
|
||||
|
||||
### arguments
|
||||
|
||||
```stylus
|
||||
sum()
|
||||
n = 0
|
||||
for num in arguments
|
||||
n = n + num
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus
|
||||
sum(1,2,3,4,5) // => 15
|
||||
```
|
||||
|
||||
参数 local 可用于所有函数体,并包含所有传递的参数
|
||||
|
||||
### hash 示例
|
||||
|
||||
```stylus
|
||||
get(hash, key)
|
||||
return pair[1] if pair[0] == key for pair in hash
|
||||
|
||||
hash = (one 1) (two 2) (three 3)
|
||||
|
||||
get(hash, two)
|
||||
// => 2
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
值 Values
|
||||
------
|
||||
|
||||
### 条件赋值
|
||||
|
||||
```stylus {2}
|
||||
royal-blue = #36a
|
||||
royal-blue ?= #89f
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus
|
||||
div
|
||||
color: royal-blue // #36a
|
||||
```
|
||||
|
||||
`?=` 只会在之前未设置的情况下设置变量
|
||||
|
||||
另见: [条件赋值](https://stylus-lang.com/docs/operators.html#conditional-assignment--)
|
||||
|
||||
### 属性查找
|
||||
|
||||
```stylus {2,3}
|
||||
.logo
|
||||
width: w = 150
|
||||
margin-left: -(w / 2)
|
||||
// or
|
||||
height: 80px
|
||||
margin-top: -(@height / 2)
|
||||
```
|
||||
|
||||
另见: [属性查找](https://stylus-lang.com/docs/variables.html#property-lookup)
|
||||
|
||||
### 插值
|
||||
|
||||
```stylus
|
||||
-{prefix}-border-radius: 2px
|
||||
```
|
||||
|
||||
另见: [Interpolation](https://stylus-lang.com/docs/interpolation.html)
|
||||
|
||||
### Color operators
|
||||
|
||||
```stylus
|
||||
#888 + 50% // → #c3c3c3 (lighten)
|
||||
#888 - 50% // → #444 (darken)
|
||||
#f00 + 50deg // → #ffd500 (hue)
|
||||
```
|
||||
|
||||
### Casting
|
||||
|
||||
```stylus
|
||||
n = 5px
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus {1,2}
|
||||
foo: (n)em
|
||||
foo: (n * 5)%
|
||||
```
|
||||
|
||||
### Lookup
|
||||
|
||||
```stylus {3}
|
||||
light-blue = #3bd
|
||||
name = 'blue'
|
||||
lookup('light-' + name)
|
||||
```
|
||||
|
||||
另见: [lookup](https://stylus-lang.com/docs/bifs.html#lookupname)
|
||||
|
||||
高级功能
|
||||
-----------------
|
||||
|
||||
### 有条件的
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```stylus
|
||||
if color == blue
|
||||
display: block
|
||||
else if true and true
|
||||
display: inline
|
||||
else if 'hey' is not 'bye'
|
||||
display: flex
|
||||
else
|
||||
display: none
|
||||
```
|
||||
|
||||
别名:
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
| `==` | `is` |
|
||||
| `!=` | `is not` |
|
||||
| `!=` | `isnt` |
|
||||
|
||||
另见: [Conditionals](https://stylus-lang.com/docs/functions.html#conditionals)
|
||||
|
||||
### 对于循环
|
||||
|
||||
```stylus {5}
|
||||
font-size-1 = 10px
|
||||
font-size-2 = 20px
|
||||
font-size-3 = 30px
|
||||
for i in 1..3
|
||||
.text-{i}
|
||||
font-size: lookup('font-size-' + i)
|
||||
```
|
||||
### 定义检查
|
||||
|
||||
```stylus {1}
|
||||
if ohnoes is defined
|
||||
color: blue
|
||||
```
|
||||
|
||||
另见: [is defined](https://stylus-lang.com/docs/operators.html#variable-definition-is-defined)
|
||||
|
||||
### False 值
|
||||
|
||||
```stylus
|
||||
0
|
||||
null
|
||||
false
|
||||
''
|
||||
```
|
||||
|
||||
### 类型检查
|
||||
|
||||
```stylus
|
||||
if val is a 'string'
|
||||
if val is a 'ident'
|
||||
if #fff is a 'rgba' // → true
|
||||
```
|
||||
|
||||
另见: [Instance check](https://stylus-lang.com/docs/operators.html#instance-check-is-a)
|
||||
|
||||
内置函数
|
||||
------------------
|
||||
|
||||
### 颜色函数
|
||||
<!--rehype:wrap-class=row-span-4-->
|
||||
|
||||
```stylus
|
||||
alpha(#fff) //→ 1
|
||||
alpha(rgba(0, 0, 0, 0.2)) //→ 0.2
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus
|
||||
dark(black) //→ true
|
||||
light(black) //→ false
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus
|
||||
hue(#0a0) //→ 50deg
|
||||
saturation(#f00) //→ 100%
|
||||
lightness(#f00) //→ 50%
|
||||
luminosity(#f00) //→ 0.2126
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus
|
||||
hue(#0a0, 0deg)
|
||||
saturation(#f00, 50%)
|
||||
lightness(#f00)
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus
|
||||
lighten(color, 10%)
|
||||
darken(color, 10%)
|
||||
saturate(color, 10%)
|
||||
desaturate(color, 10%)
|
||||
invert(color)
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus
|
||||
tint(color, 50%) // mix with white
|
||||
shade(color, 50%) // mix with black
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus
|
||||
unquote(string)
|
||||
```
|
||||
|
||||
另见: [Built-in functions](http://stylus-lang.com/docs/bifs.html)
|
||||
|
||||
### 图片尺寸
|
||||
|
||||
返回给定图像的宽度和高度
|
||||
|
||||
```stylus
|
||||
width: image-size('tux.png')[0]
|
||||
height: image-size('tux.png')[1]
|
||||
```
|
||||
|
||||
另见: [image-size](http://stylus-lang.com/docs/bifs.html#image-sizepath)
|
||||
|
||||
### 缓存 Caching
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```stylus
|
||||
size($width)
|
||||
+cache('w' + $width)
|
||||
width: $width
|
||||
.a { size: 10px }
|
||||
.b { size: 10px }
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus
|
||||
// 输出: .a, b { width: 10px }
|
||||
```
|
||||
|
||||
在第一次调用时将其内容应用于给定的选择器,但会在第二次调用时使用相同的参数 `@extend` 第一次调用的选择器。另见: [cache](http://stylus-lang.com/docs/bifs.html#cachekeys)
|
||||
|
||||
### Embed URL
|
||||
|
||||
```
|
||||
background: embedurl('logo.png')
|
||||
// → background: url("data:image/png;base64,…")
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
另见: [embedurl](http://stylus-lang.com/docs/bifs.html#embedurlpath-encoding)
|
||||
|
||||
### 添加属性
|
||||
|
||||
```stylus
|
||||
gradient(color)
|
||||
add-property('background-image', linear-gradient(top, color, darken(color, 20%)))
|
||||
color
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```stylus
|
||||
body
|
||||
background: gradient(red)
|
||||
```
|
||||
|
||||
另见: [add-property](http://stylus-lang.com/docs/bifs.html#add-propertyname-expr)
|
||||
|
||||
### sprintf
|
||||
|
||||
```stylus
|
||||
'-webkit-gradient(%s, %s, %s)' % (linear (0 0) (0 100%))
|
||||
// → -webkit-gradient(linear, 0 0, 0 100%)
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
----
|
||||
|
||||
```stylus
|
||||
s("rgba(0, 0, 0, %s)", 0.3)
|
||||
```
|
||||
|
||||
另见: [s](http://stylus-lang.com/docs/bifs.html#sfmt-)
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
- [CSS 备忘清单](./css.md) _(jaywcjlove.github.io)_
|
||||
- [在线编译预览](https://stylus-lang.com/try.html) _(stylus-lang.com)_
|
||||
- [Less.js 备忘清单](./lessjs.md) _(jaywcjlove.github.io)_
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wcj/reference",
|
||||
"version": "1.5.0",
|
||||
"version": "1.7.0",
|
||||
"description": "为开发人员分享快速参考备忘单(主要是方便自己)。",
|
||||
"author": "jaywcjlove",
|
||||
"license": "MIT",
|
||||
|
1
scripts/assets/expressjs.svg
Normal file
1
scripts/assets/expressjs.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 230 230" height="1em" width="1em"><path d="M176.09375,0 C205.86535,-5.46895416e-15 230,24.1346502 230,53.90625 L230,176.09375 C230,205.86535 205.86535,230 176.09375,230 L53.90625,230 C24.1346502,230 3.64596944e-15,205.86535 0,176.09375 L0,53.90625 C-3.64596944e-15,24.1346502 24.1346502,5.46895416e-15 53.90625,0 L176.09375,0 Z M96.3915625,71.8417578 C72.1633984,52.8083594 36.9455469,65.5976172 28.3034766,96.3196875 C26.8542969,101.414727 26.205625,106.860156 25.15625,111.855469 C25.15625,114.753001 25.1735062,117.650508 25.2065625,120.547852 C25.5560547,122.146172 26.205625,123.845117 26.205625,125.543164 C27.040801,136.25108 31.3566466,146.391645 38.4944531,154.417148 C53.2945034,168.337492 75.3687421,171.159676 93.1949219,161.410586 C103.851236,155.025409 110.993734,144.108874 112.576914,131.787305 C107.831367,130.339023 105.333711,131.188047 103.784805,136.183359 C101.384533,146.161673 94.1154179,154.257423 84.4522266,157.714414 C55.1290234,167.505586 32.2,148.323047 33.4991406,116.551602 L113.426836,116.551602 C114.12582,98.7679297 110.578789,82.9823828 96.3915625,71.8417578 Z M134.6075,70.6917578 C131.648507,65.8588504 125.699893,63.7717491 120.369961,65.6964453 L156.287695,112.505039 L117.672852,164.308047 C122.86047,166.177143 128.629968,163.911928 131.160195,159.012656 C140.551562,145.274648 150.842266,132.03707 161.132969,118.249648 L164.880352,123.244961 C173.522422,135.133984 182.513984,146.773242 190.656523,158.962344 C193.339516,164.091123 199.430792,166.407513 204.84375,164.357461 C192.654648,148.072383 180.815937,132.187109 168.876602,116.35125 C167.81759,115.403944 167.212286,114.050351 167.212286,112.629473 C167.212286,111.208595 167.81759,109.855001 168.876602,108.907695 C175.370508,100.864883 181.514922,92.5723047 187.759062,84.3300391 L201.696523,65.8464844 C196.612958,63.8698897 190.855156,66.0182947 188.308906,70.8417969 C179.766562,82.9311719 170.624961,94.6207422 161.382734,106.860156 C152.191719,94.5210156 142.949492,82.8817578 134.6075,70.6917578 Z M70.8691642,70.1898981 L71.5147266,70.1940234 C90.8967188,70.3431641 105.433437,86.6785547 105.883555,109.707305 L33.5988672,109.707305 L33.5485547,109.607578 C34.4982031,85.8789453 49.9342578,69.8939453 71.5147266,70.1940234 Z"/></svg>
|
After Width: | Height: | Size: 2.3 KiB |
14
scripts/assets/github-actions.svg
Normal file
14
scripts/assets/github-actions.svg
Normal file
@ -0,0 +1,14 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="1em" height="1em" viewBox="0 0 107 107">
|
||||
<g fill="none" fill-rule="evenodd" transform="translate(2.982 2.982)">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="4.393" d="M19.7678571,0 C30.6853432,0 39.5357143,8.85037111 39.5357143,19.7678571 C39.5357143,30.6853432 30.6853432,39.5357143 19.7678571,39.5357143 C8.85037111,39.5357143 0,30.6853432 0,19.7678571 C0,8.85037111 8.85037111,0 19.7678571,0 L19.7678571,0 Z M48.3214286,39.5357143 C55.5997526,39.5357143 61.5,45.4359617 61.5,52.7142857 C61.5,59.9926097 55.5997526,65.8928571 48.3214286,65.8928571 C41.0431045,65.8928571 35.1428571,59.9926097 35.1428571,52.7142857 C35.1428571,45.4359617 41.0431045,39.5357143 48.3214286,39.5357143 Z M48.3214286,74.6785714 C55.5997526,74.6785714 61.5,80.5788188 61.5,87.8571429 C61.5,95.1354669 55.5997526,101.035714 48.3214286,101.035714 C41.0431045,101.035714 35.1428571,95.1354669 35.1428571,87.8571429 C35.1428571,80.5788188 41.0431045,74.6785714 48.3214286,74.6785714 Z"/>
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="4.393" d="M87.8571429,74.6785714 C95.1354669,74.6785714 101.035714,80.5788188 101.035714,87.8571429 C101.035714,95.1354669 95.1354669,101.035714 87.8571429,101.035714 C80.5788188,101.035714 74.6785714,95.1354669 74.6785714,87.8571429 C74.6785714,80.5788188 80.5788188,74.6785714 87.8571429,74.6785714 Z"/>
|
||||
<polyline stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="4.393" points="52.793 49.655 46.05 56.387 42.778 53.125"/>
|
||||
<g stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="4.393" transform="translate(74.679 39.536)">
|
||||
<path d="M13.1785714,0 C20.4568955,0 26.3571429,5.9002474 26.3571429,13.1785714 C26.3571429,20.4568955 20.4568955,26.3571429 13.1785714,26.3571429 C5.9002474,26.3571429 0,20.4568955 0,13.1785714 C0,5.9002474 5.9002474,0 13.1785714,0 Z"/>
|
||||
<polyline points="17.651 10.119 10.907 16.851 7.635 13.589"/></g>
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="4.393" d="M16.5456964,10.9074643 L27.7760357,17.9799643 C28.4178266,18.3833884 28.8062276,19.0892404 28.8035611,19.8472901 C28.8008672,20.6053399 28.4074847,21.3084277 27.7628571,21.7073036 L16.5325179,28.6699821 C15.8550724,29.0900649 15.0032059,29.1101448 14.3067197,28.7224479 C13.6102335,28.3347509 13.1785714,27.6001388 13.1785714,26.8030179 L13.1785714,12.7656429 C13.1785714,11.9658375 13.6135044,11.2293022 14.3137561,10.8428619 C15.0140079,10.4564216 15.8689689,10.481168 16.5456964,10.9074643 L16.5456964,10.9074643 Z M17.5714286,39.5357143 L17.5714286,72.4821429 C17.5714286,80.9735357 24.5494821,87.8571429 32.9464286,87.8571429 L35.1428571,87.8571429"/>
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="4.393" d="M17.5714286,39.6125893 C17.5714286,46.8484564 23.4372579,52.7142857 30.673125,52.7142857 L35.0308393,52.7142857 M61.6208036,52.7142857 L74.6785714,52.7142857"/>
|
||||
<path fill="currentColor" fill-rule="nonzero" d="M43.9285714,85.660714 C44.7136722,85.6611066 45.4389259,86.0803154 45.8311365,86.7604287 C46.223347,87.4405421 46.2229284,88.2782346 45.8300382,88.9579556 C45.4371481,89.6376766 44.7114757,90.0561603 43.926375,90.0557681 C42.7127145,90.0551613 41.72934,89.0708033 41.7299463,87.8571429 C41.7305531,86.6434824 42.7149109,85.6601078 43.9285714,85.660714 M52.7142857,85.660714 C53.4993864,85.6611066 54.2246401,86.0803154 54.6168507,86.7604287 C55.0090613,87.4405421 55.0086427,88.2782346 54.6157525,88.9579556 C54.2228624,89.6376766 53.49719,90.0561603 52.7120893,90.0557681 C51.4984288,90.0551613 50.5150543,89.0708033 50.5156606,87.8571429 C50.5162674,86.6434824 51.5006252,85.6601078 52.7142857,85.660714"/>
|
||||
<line x1="72.493" x2="70.268" y1="87.873" y2="87.945" stroke="currentColor" stroke-linecap="round" stroke-width="4.393"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.9 KiB |
3
scripts/assets/homebrew.svg
Normal file
3
scripts/assets/homebrew.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em">
|
||||
<path d="M7.938 0a.214.214 0 0 0-.206.156c-.316 1.104.179 2.15.838 2.935.153.181.313.347.476.501a2.039 2.039 0 0 0-.665.02c-1.184.233-2.193.985-2.74 2.532a3.893 3.893 0 0 0-.2 1.466 1.565 1.565 0 0 0-1.156 1.504 1.59 1.59 0 0 0 1.227 1.541l.026 12.046c0 .195.1.377.264.482a.214.214 0 0 0 .008.005c.537.31 2.047.812 5.21.812 3.238 0 4.7-.678 5.181-1.04a.214.214 0 0 0 .008-.007.571.571 0 0 0 .206-.439c.002-.344.002-1.136.002-1.604a.143.143 0 0 1 .147-.144c.397.006.869.006 1.318.005a1.826 1.826 0 0 0 1.832-1.825v-5.804a1.826 1.826 0 0 0-1.825-1.826H16.56a.14.14 0 0 1-.143-.144V10.6h.007v-.001a1.573 1.573 0 0 0 1.356-1.556c0-.816-.627-1.489-1.424-1.563-.025-1.438-.437-2.126-.736-2.58a.214.214 0 0 0-.005-.007c-.364-.51-1.193-1.282-2.275-1.316-.503-.016-.842.124-1.125.254-.217.1-.42.177-.67.22.002-1.286.945-1.981.945-1.981a.214.214 0 0 0 .05-.298s-.087-.122-.21-.26c-.121-.136-.269-.294-.47-.378a.214.214 0 0 0-.079-.017.214.214 0 0 0-.145.055 4.308 4.308 0 0 0-.875 1.101 3.42 3.42 0 0 0-.133.273 3.497 3.497 0 0 0-.381-.846C9.794.978 9.063.436 8.017.016A.214.214 0 0 0 7.939 0zm.156.524c.85.378 1.43.83 1.79 1.403.274.438.426.962.484 1.584a3.07 3.07 0 0 0-.012.462 6.897 6.897 0 0 1-.168-.052 5.487 5.487 0 0 1-1.29-1.106c-.551-.657-.935-1.46-.804-2.291zM11.8 1.618c.07.054.141.101.212.18.034.039.032.04.058.073-.332.308-1.07 1.144-.952 2.453a.214.214 0 0 0 .222.195c.469-.017.782-.172 1.056-.299.273-.126.508-.228.931-.214.875.027 1.639.715 1.939 1.134.295.449.65 1 .663 2.36a1.66 1.66 0 0 0-.41.142 1.938 1.938 0 0 0-1.77-1.16 1.94 1.94 0 0 0-1.87 1.448 1.783 1.783 0 0 0-1.356-.64c-.484 0-.91.205-1.233.517a1.873 1.873 0 0 0-1.85-1.625c-.649 0-1.218.335-1.552.84a3.1 3.1 0 0 1 .157-.735c.51-1.437 1.355-2.045 2.42-2.254.367-.073.664-.011.99.095.325.106.671.262 1.094.342a.214.214 0 0 0 .252-.245c-.112-.67.073-1.266.336-1.744a3.71 3.71 0 0 1 .663-.863zM7.44 6.611a1.442 1.442 0 0 1 1.363 1.925.214.214 0 0 0 .168.283h.005a.214.214 0 0 0 .238-.146 1.373 1.373 0 0 1 2.613-.01.214.214 0 0 0 .417-.09 1.509 1.509 0 0 1 1.504-1.664c.678 0 1.249.445 1.442 1.056a.214.214 0 0 0 .259.143l.15-.04a.214.214 0 0 0 .051-.02 1.139 1.139 0 0 1 1.702.995 1.14 1.14 0 0 1-.985 1.131.214.214 0 0 0-.001 0 2.215 2.215 0 0 0-.485.126 10.65 10.65 0 0 1-1.176.365.214.214 0 0 0-.162.186 1.276 1.276 0 0 1-.146.478 2.07 2.07 0 0 0-.239 1.111l.001.151a.438.438 0 0 1-.16.36.665.665 0 0 1-.43.14.586.586 0 0 1-.588-.59.803.803 0 0 0-.38-.681.214.214 0 0 0-.002-.002c-.24-.145-.43-.37-.532-.636a.214.214 0 0 0-.207-.138 19.469 19.469 0 0 1-5.37-.6l-.003-.002a9.007 9.007 0 0 0-.838-.194h.003a1.16 1.16 0 0 1-.937-1.134c0-.619.488-1.118 1.101-1.14a.214.214 0 0 0 .204-.176 1.443 1.443 0 0 1 1.42-1.187zm8.549 4.106v.455c0 .314.259.573.572.573h1.329a1.397 1.397 0 0 1 1.397 1.397v5.804a1.396 1.396 0 0 1-1.402 1.396.214.214 0 0 0-.002 0c-.448.002-.918 0-1.31-.005a.573.573 0 0 0-.584.573c0 .468 0 1.262-.002 1.603a.214.214 0 0 0 0 .001c0 .042-.019.08-.05.107-.346.26-1.75.95-4.915.95-3.107 0-4.587-.52-4.99-.752a.143.143 0 0 1-.065-.118l-.025-11.955c.145.033.288.07.431.11a.214.214 0 0 0 .003 0c.115.031.246.064.383.097v10.37c0 .129.069.247.18.31.453.217 1.767.732 4.071.732 2.32 0 3.595-.626 4.022-.884a.357.357 0 0 0 .164-.3l.001-10.21c.267-.075.531-.158.792-.254zm-7.99.894a.493.493 0 0 1 .494.493v8.578a.493.493 0 0 1-.493.493.493.493 0 0 1-.494-.493v-8.578A.493.493 0 0 1 8 11.611zm8.652 1.14a.663.663 0 0 0-.662.662v5.208a.663.663 0 0 0 .662.662h1.14a.663.663 0 0 0 .662-.662v-5.209a.663.663 0 0 0-.662-.662zm0 .428h1.14a.233.233 0 0 1 .233.233v5.21a.233.233 0 0 1-.233.232h-1.14a.233.233 0 0 1-.233-.233v-5.209a.233.233 0 0 1 .233-.233z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 3.7 KiB |
1
scripts/assets/koajs.svg
Normal file
1
scripts/assets/koajs.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="1em" height="1em" viewBox="0 0 230 230"><path d="M176.09375,0 C205.86535,-5.46895416e-15 230,24.1346502 230,53.90625 L230,176.09375 C230,205.86535 205.86535,230 176.09375,230 L53.90625,230 C24.1346502,230 3.64596944e-15,205.86535 0,176.09375 L0,53.90625 C-3.64596944e-15,24.1346502 24.1346502,5.46895416e-15 53.90625,0 L176.09375,0 Z M46.6655391,74 L39,74 L39,156 L46.6655391,156 L46.6655391,129.650518 L49.6224434,126.261287 L69.8814961,156 L77.547334,156 L54.002666,121.450727 L71.8528652,101.333433 L70.7576602,101.333433 L46.6655391,128.447878 L46.6655391,74 Z M166.63517,101.605824 C155.279402,101.605824 148.80559,105.323536 147.426199,105.960807 L147.850535,106.70429 C150.50383,105.217325 158.675584,102.455817 165.255779,102.455817 C175.471142,102.455817 176.406034,109.037681 176.428332,111.278315 L176.428388,111.441925 C176.424978,111.802842 176.39908,112.014881 176.39908,112.014881 L176.39908,129.646341 C175.125475,129.54013 169.7131,129.327706 164.937229,129.752553 C146.046211,131.027095 143.499299,136.337984 144.560438,143.454176 C145.19724,147.702947 147.319816,155.562622 159.737021,155.562622 C170.24352,155.562622 174.276504,149.933396 176.39908,146.10977 L176.39908,147.596736 C176.39908,147.596736 176.396486,147.62746 176.394995,147.684985 L176.394581,147.834611 C176.41733,149.115868 177.139684,155.137775 188.709902,155.137775 L192,155.137476 L192,154.287782 L188.70601,154.287921 C188.703429,154.288003 188.699579,154.288109 188.694503,154.288209 L188.616885,154.288028 C187.942429,154.274794 183.828246,153.934323 183.828246,147.596437 L183.828246,112.015179 C183.828246,108.403679 182.023922,101.605824 166.63517,101.605824 Z M111.11141,101.498121 C96.1873359,101.498121 84.7236914,111.37582 84.7236914,129.113791 C84.7236914,148.44464 96.5115645,155.45462 110.246303,155.45462 C125.170377,155.45462 136.634021,145.576921 136.634021,127.839249 C136.634021,108.508101 124.846148,101.498121 111.11141,101.498121 Z M164.943803,130.353127 C170.178674,129.705713 175.099477,130.137422 176.356049,130.245125 L176.356049,143.304406 C176.041682,147.621499 169.550537,154.852853 161.593939,154.852853 C154.26518,154.852853 152.694838,148.700921 152.275881,143.412408 C151.647744,135.533639 153.846521,131.648255 164.943803,130.353127 Z M111.117088,102.20789 C121.305932,102.20789 129.523107,109.148952 129.523107,127.835669 C129.523107,144.920854 120.97752,154.744851 110.240625,154.744851 C100.051482,154.744851 91.8346055,147.804087 91.8346055,129.117072 C91.8346055,112.031887 100.380193,102.20789 111.117088,102.20789 Z"/></svg>
|
After Width: | Height: | Size: 2.6 KiB |
2
scripts/assets/lessjs.svg
Normal file
2
scripts/assets/lessjs.svg
Normal file
@ -0,0 +1,2 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em" viewBox="0 0 210 90">
|
||||
<path d="M201.009375,32.7796875 C201.009375,26.053125 202.059375,22.0828125 202.059375,14.8640625 C202.059375,3.6421875 197.925,0.0328125 188.770313,0.0328125 L182.04375,0.0328125 L182.04375,7.9734375 L184.110938,7.9734375 C188.770313,7.9734375 189.7875,9.515625 189.7875,15.225 C189.7875,20.5734375 189.2625,25.921875 189.2625,32.1234375 C189.2625,40.0640625 191.854687,43.1484375 197.00625,44.3625 L197.00625,44.8875 C191.821875,46.1015625 189.2625,49.1859375 189.2625,57.1265625 C189.2625,63.328125 189.7875,68.3484375 189.7875,74.025 C189.7875,79.8984375 188.573437,81.440625 184.110938,81.440625 L184.110938,81.6046875 L182.04375,81.6046875 L182.04375,89.8734375 L188.770313,89.8734375 C197.892188,89.8734375 202.059375,86.2640625 202.059375,75.0421875 C202.059375,67.6265625 201.009375,63.8203125 201.009375,57.1265625 C201.009375,53.5171875 203.240625,49.7109375 209.967187,49.3828125 L209.967187,40.425 C203.240625,40.1953125 201.009375,36.3890625 201.009375,32.7796875 Z M166.359375,43.2796875 C161.175,41.2125 156.351562,39.9984375 156.351562,36.553125 C156.351562,33.9609375 158.41875,32.41875 162.225,32.41875 C166.03125,32.41875 169.476562,33.9609375 173.25,36.7171875 L180.140625,27.5953125 C175.842187,24.3140625 169.96875,20.86875 162.028125,20.86875 C150.314063,20.86875 142.373438,27.5953125 142.373438,37.078125 C142.373438,45.5109375 149.789063,49.8421875 155.990625,52.2375 C161.339063,54.3046875 166.523438,56.04375 166.523438,59.4890625 C166.523438,62.08125 164.45625,63.7875 159.796875,63.7875 C155.498438,63.7875 151.167188,62.0484375 146.507813,58.4390625 L139.617188,68.446875 C144.801563,72.7453125 152.709375,75.6984375 159.271875,75.6984375 C173.053125,75.6984375 180.46875,68.446875 180.46875,58.9640625 C180.46875,49.48125 173.085938,45.5109375 166.359375,43.2796875 L166.359375,43.2796875 Z M48.5953125,62.7703125 C47.38125,62.7703125 45.8390625,61.7203125 45.8390625,58.471875 L45.8390625,7.10542736e-15 L21.3609375,7.10542736e-15 C12.0421875,7.10542736e-15 7.9078125,3.609375 7.9078125,14.83125 C7.9078125,22.246875 8.9578125,26.38125 8.9578125,32.746875 C8.9578125,36.35625 6.7265625,40.1625 -6.99440506e-15,40.490625 L-6.99440506e-15,49.4484375 C6.7265625,49.6125 8.9578125,53.41875 8.9578125,57.028125 C8.9578125,63.39375 7.9078125,67.2 7.9078125,74.615625 C7.9078125,85.8375 12.0421875,89.446875 21.196875,89.446875 L27.9234375,89.446875 L27.9234375,81.50625 L25.85625,81.50625 C21.5578125,81.50625 20.1796875,79.7671875 20.1796875,74.090625 C20.1796875,68.4140625 20.7046875,63.5578125 20.7046875,57.1921875 C20.7046875,49.2515625 18.1125,46.1671875 12.9609375,44.953125 L12.9609375,44.428125 C18.1453125,43.2140625 20.7046875,40.1296875 20.7046875,32.1890625 C20.7046875,25.9875 20.1796875,20.9671875 20.1796875,15.290625 C20.1796875,9.6140625 21.39375,8.0390625 25.85625,8.0390625 L30.4828125,8.0390625 L30.4828125,57.5203125 C30.4828125,68.053125 34.0921875,74.94375 44.625,74.94375 C47.90625,74.94375 50.4984375,74.41875 52.36875,73.7296875 L50.6296875,62.5078125 C49.6125,62.7703125 49.1203125,62.7703125 48.5953125,62.7703125 Z M124.621875,43.2796875 C119.273437,41.2125 114.45,39.9984375 114.45,36.553125 C114.45,33.9609375 116.517187,32.41875 120.323437,32.41875 C124.129687,32.41875 127.575,33.9609375 131.348437,36.7171875 L138.239062,27.5953125 C133.940625,24.3140625 128.067187,20.86875 120.126562,20.86875 C108.4125,20.86875 100.471875,27.5953125 100.471875,37.078125 C100.471875,45.5109375 107.8875,49.8421875 114.089062,52.2375 C119.4375,54.3046875 124.621875,56.04375 124.621875,59.4890625 C124.621875,62.08125 122.554687,63.7875 117.895312,63.7875 C113.596875,63.7875 109.265625,62.0484375 104.60625,58.4390625 L97.8796875,68.446875 C103.064062,72.7453125 110.971875,75.6984375 117.534375,75.6984375 C131.315625,75.6984375 138.731358,68.446875 138.731358,58.9640625 C138.764062,49.48125 131.348437,45.5109375 124.621875,43.2796875 Z M73.7625,20.7046875 C61.1625,20.7046875 49.1203125,31.2375 49.4484375,47.775 C49.4484375,64.8375 60.6703125,74.8453125 75.46875,74.8453125 C81.6703125,74.8453125 88.5609375,72.6140625 93.909375,68.971875 L88.725,59.85 C84.91875,62.08125 81.309375,63.13125 77.503125,63.13125 C70.6125,63.13125 65.2640625,59.85 63.8859375,51.909375 L95.1234375,51.909375 C95.2875,50.6953125 95.6484375,48.3 95.6484375,45.54375 C95.8453125,31.565625 88.2328125,20.7046875 73.7625,20.7046875 L73.7625,20.7046875 Z M63.91875,42.4265625 C64.96875,35.5359375 69.103125,32.2546875 73.9265625,32.2546875 C80.128125,32.2546875 82.55625,36.553125 82.55625,42.4265625 L63.91875,42.4265625 L63.91875,42.4265625 Z" transform="translate(.033 .08)"/></svg>
|
After Width: | Height: | Size: 4.6 KiB |
3
scripts/assets/stylus.svg
Normal file
3
scripts/assets/stylus.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em" viewBox="0 0 64 64">
|
||||
<path d="M9.864 42.916c1.66-1.986 1.855-4.036.57-7.844-.814-2.4-2.165-4.264-1.172-5.76 1.058-1.595 3.304-.05 1.432 2.083l.374.26c2.246.26 3.353-2.816 1.676-3.694-4.427-2.3-8.3 2.132-6.6 7.275.732 2.18 1.758 4.492.928 6.33-.716 1.58-2.1 2.506-3.027 2.54-1.937.098-.65-4.345 1.58-5.452.195-.098.472-.228.212-.553-2.75-.3-4.362.96-5.3 2.734-2.702 5.16 5.126 7.063 9.3 2.083zM58.2 27.748c.635 1.562 1.595 3.108 1.025 4.476-.472 1.172-1.1 1.66-1.774 1.774-.96.163-.7-2.848.944-3.743.146-.08.358-.472.163-.7-2.083-.114-3.255.88-3.9 2.197-1.84 3.857 4.166 4.915 7.112 1.123 1.172-1.514 1.22-3 .098-5.73-.716-1.725-1.806-3-1.123-4.15.732-1.204 2.5-.163 1.172 1.448l.293.163c1.7.098 2.4-2.18 1.107-2.75-3.434-1.465-6.64 2.23-5.126 5.9zM36.456 23.63c-1.188-.944-4.524.635-5.468 2.978-1.188 2.978-2.946 7.324-4.67 9.228-1.823 2.002-2.002.456-1.823-.7.423-2.718 3.076-9.016 4.524-10.8-.537-.797-4.052-.684-6.494 3.108-.9 1.432-2.995 6.2-5.306 9.96-.505.814-1.14.244-.65-1.66.553-2.197 2.18-8.235 4.28-12.987 5.5-1.1 11.343-1.855 15.82-1.872.602-.163 1-.7 0-.732-3.857-.13-9.65.325-15.07 1 1.04-2.063 2.163-3.733 3.3-4.433-1.237-.78-3.743-.472-5.175 1.644-.635.944-1.27 2.083-1.872 3.32-3.97.618-7.372 1.318-9.098 1.97-1.8.684-1.595 2.848-.505 2.44 2.262-.846 5.322-1.725 8.723-2.506-2.165 4.882-3.857 10.644-4.264 12.987-1 5.696 2.523 5.664 4.248 3.418 1.872-2.457 5.777-11.1 6.38-12 .18-.3.423-.146.293.13-4.362 8.707-3.987 12.076-.456 11.327 1.595-.342 4.345-3.076 5.06-4.492.146-.342.456-.3.4-.163-2.767 7.177-6.282 12.987-8.642 14.8-2.148 1.644-3.743-1.92 3.857-7.03 1.123-.765.602-1.806-.667-1.448-3.922.618-15.152 4.183-20.083 7.6-.374.26-.716.472-.7 1 .016.3.553.195.814.033 6.38-3.825 11.604-5.322 17.593-6.575.08.033.18.05.26.016.277-.065.26.08.08.195-.407.228-.814.44-.9.472-4.036 1.58-6.477 5.06-5.615 6.835.732 1.53 4.687.976 6.56-.033 4.6-2.5 7.926-7.372 10.204-14.1 1.986-5.973 4.492-12.743 5.078-12.938zM63.13 37.415c-7.47-.976-23.582.325-30.694 2.213-2.116.553-1.53 1.676-.456 1.465.016 0 .472-.114.488-.114 5.843-1.14 20.018-2.132 28.285-.553.993.18 3.97-2.8 2.376-3zm-24.6-.88c2.083-1.042 5.175-7.486 7.2-11.018.146-.26.407-.05.26.13-5.143 8.853-2.962 9.88-.928 9.748 2.718-.163 5.224-4.07 5.777-4.947.228-.342.358-.065.228.18-.13.407-.602 1.123-1.042 2.1-.618 1.383.033 1.92.57 2.165.846.407 3.157.146 3.515-1.27-2.3-.05 3.222-10.953 3.792-11.62-1.546-.895-3.938.08-5.03 2.23-2.327 4.606-4.28 8.316-5.5 8.38-2.376.13 2.734-10.27 3.564-10.595-.505-.732-3.743-.423-5.55 2.376-.65 1-4.622 8.04-5.598 9.195-1.725 2.05-1.855.293-1.367-1.758.163-.7.44-1.595.797-2.588 1.14-2.57 2.36-3.385 3.108-4.215 5.03-5.582 7.9-10.107 6.77-11.88-1-1.58-4.378-.88-6.542 2.376-3.987 5.973-7.665 14.16-8.137 17.902-.456 3.743 2.262 4.02 4.1 3.108zm2.116-10.953c.18-.407.293-.52.602-1.204 1.8-3.938 4.036-8.088 5.582-10.025.96-1 2.3.358-.13 4.1a37.625 37.625 0 0 1-4.834 6.038c-.456.52-.863.944-1.042 1.188-.13.163-.277.13-.18-.098z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 3.0 KiB |
@ -309,6 +309,11 @@ 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;
|
||||
text-decoration-color: #fff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.home-card {
|
||||
display: grid;
|
||||
@ -380,7 +385,7 @@ a.text-grey {
|
||||
}
|
||||
|
||||
.header-nav .max-container {
|
||||
padding-top: 1.8rem;
|
||||
padding: 1.8rem 1.8rem 0;
|
||||
}
|
||||
|
||||
.header-nav .max-container, .header-nav .logo, .header-nav .menu, .header-nav .menu a {
|
||||
@ -450,6 +455,8 @@ a.text-grey {
|
||||
|
||||
.wrap-header.h1wrap .wrap-body {
|
||||
color: var(--color-fg-subtle);
|
||||
max-width: 850px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.wrap-header.h1wrap > h1 {
|
||||
@ -638,7 +645,7 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
}
|
||||
.h2wrap-body ul.style-timeline li::before {
|
||||
color: #228e6c;
|
||||
background-color: #fff;
|
||||
background-color: var(--color-canvas-default);
|
||||
counter-increment: stepCount;
|
||||
content: counter(stepCount);
|
||||
border-radius: initial;
|
||||
@ -653,14 +660,15 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
left: -14px;
|
||||
}
|
||||
.h2wrap-body ul.style-timeline li:last-child {
|
||||
border-image: linear-gradient(to bottom,#228e6c,rgba(0,0,0,0)) 1 100%;
|
||||
border-image: linear-gradient(to bottom,#46c69e96,rgba(0,0,0,0)) 1 100%;
|
||||
}
|
||||
.h2wrap-body ul.style-timeline li {
|
||||
border-bottom: 0 !important;
|
||||
padding-top: 0 !important;
|
||||
padding-bottom: 25px !important;
|
||||
border-left: 2px solid #228e6c;
|
||||
border-left: 2px solid #46c69e96;
|
||||
margin-left: 30px;
|
||||
border-left-color: #46c69e96;
|
||||
}
|
||||
.h2wrap-body ul.style-timeline li > pre {
|
||||
padding: 0 !important;
|
||||
@ -908,8 +916,7 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 375px) {
|
||||
@media (375px <= width <= 1024px) {
|
||||
.header-nav .title {
|
||||
font-size: 1rem;
|
||||
}
|
||||
@ -952,6 +959,10 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
.footer-wrap {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
table {
|
||||
overflow: auto;
|
||||
display: block;
|
||||
}
|
||||
table td, table th {
|
||||
display: block;
|
||||
text-align: left !important;
|
||||
@ -959,11 +970,8 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
table td + td, table th + th {
|
||||
padding-top: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.home-card {
|
||||
grid-template-columns: repeat(4,minmax(0,1fr));
|
||||
table td:first-child {
|
||||
white-space: initial;
|
||||
}
|
||||
.wrap-header.h3wrap > .wrap-body {
|
||||
overflow: initial;
|
||||
@ -972,3 +980,9 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.home-card {
|
||||
grid-template-columns: repeat(4,minmax(0,1fr));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user