Skip to content

Commit c21ced4

Browse files
committed
chore: syncing
2 parents 1e3dd13 + da9af18 commit c21ced4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+5000
-3934
lines changed

.codesandbox/ci.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"sandboxes": ["2d17z"],
3+
"packages": [".", "packages/docsify-server-renderer"]
4+
}

.editorconfig

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# http://EditorConfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 2
9+
end_of_line = lf
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true

.github/semantic.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
titleAndCommits: true
2+
allowMergeCommits: true
3+
allowRevertCommits: true
4+
anyCommit: true

build/build.js

+73-49
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,16 @@ const version = process.env.VERSION || require('../package.json').version
99
const chokidar = require('chokidar')
1010
const path = require('path')
1111

12-
const build = function (opts) {
13-
rollup
12+
/**
13+
* @param {{
14+
* input: string,
15+
* output?: string,
16+
* globalName?: string,
17+
* plugins?: Array<import('rollup').Plugin>
18+
* }} opts
19+
*/
20+
async function build(opts) {
21+
await rollup
1422
.rollup({
1523
input: opts.input,
1624
plugins: (opts.plugins || []).concat([
@@ -27,31 +35,35 @@ const build = function (opts) {
2735
var dest = 'lib/' + (opts.output || opts.input)
2836

2937
console.log(dest)
30-
bundle.write({
38+
return bundle.write({
3139
format: 'iife',
40+
output: opts.globalName ? {name: opts.globalName} : {},
3241
file: dest,
3342
strict: false
3443
})
3544
})
36-
.catch(function (err) {
37-
console.error(err)
38-
})
3945
}
40-
const buildCore = function () {
41-
build({
46+
47+
async function buildCore() {
48+
const promises = []
49+
50+
promises.push(build({
4251
input: 'src/core/index.js',
43-
output: 'docsify.js'
44-
})
52+
output: 'docsify.js',
53+
}))
4554

4655
if (isProd) {
47-
build({
56+
promises.push(build({
4857
input: 'src/core/index.js',
4958
output: 'docsify.min.js',
5059
plugins: [uglify()]
51-
})
60+
}))
5261
}
62+
63+
await Promise.all(promises)
5364
}
54-
const buildAllPlugin = function () {
65+
66+
async function buildAllPlugin() {
5567
var plugins = [
5668
{name: 'search', input: 'search/index.js'},
5769
{name: 'ga', input: 'ga.js'},
@@ -64,56 +76,68 @@ const buildAllPlugin = function () {
6476
{name: 'gitalk', input: 'gitalk.js'}
6577
]
6678

67-
plugins.forEach(item => {
68-
build({
79+
const promises = plugins.map(item => {
80+
return build({
6981
input: 'src/plugins/' + item.input,
7082
output: 'plugins/' + item.name + '.js'
7183
})
7284
})
7385

7486
if (isProd) {
7587
plugins.forEach(item => {
76-
build({
88+
promises.push(build({
7789
input: 'src/plugins/' + item.input,
7890
output: 'plugins/' + item.name + '.min.js',
7991
plugins: [uglify()]
80-
})
92+
}))
8193
})
8294
}
95+
96+
await Promise.all(promises)
8397
}
8498

85-
if (!isProd) {
86-
chokidar
87-
.watch(['src/core', 'src/plugins'], {
88-
atomic: true,
89-
awaitWriteFinish: {
90-
stabilityThreshold: 1000,
91-
pollInterval: 100
92-
}
93-
})
94-
.on('change', p => {
95-
console.log('[watch] ', p)
96-
const dirs = p.split(path.sep)
97-
if (dirs[1] === 'core') {
98-
buildCore()
99-
} else if (dirs[2]) {
100-
const name = path.basename(dirs[2], '.js')
101-
const input = `src/plugins/${name}${
102-
/\.js/.test(dirs[2]) ? '' : '/index'
103-
}.js`
99+
async function main() {
100+
if (!isProd) {
101+
chokidar
102+
.watch(['src/core', 'src/plugins'], {
103+
atomic: true,
104+
awaitWriteFinish: {
105+
stabilityThreshold: 1000,
106+
pollInterval: 100
107+
}
108+
})
109+
.on('change', p => {
110+
console.log('[watch] ', p)
111+
const dirs = p.split(path.sep)
112+
if (dirs[1] === 'core') {
113+
buildCore()
114+
} else if (dirs[2]) {
115+
const name = path.basename(dirs[2], '.js')
116+
const input = `src/plugins/${name}${
117+
/\.js/.test(dirs[2]) ? '' : '/index'
118+
}.js`
104119

105-
build({
106-
input,
107-
output: 'plugins/' + name + '.js'
108-
})
109-
}
110-
})
111-
.on('ready', () => {
112-
console.log('[start]')
113-
buildCore()
120+
build({
121+
input,
122+
output: 'plugins/' + name + '.js'
123+
})
124+
}
125+
})
126+
.on('ready', () => {
127+
console.log('[start]')
128+
buildCore()
129+
buildAllPlugin()
130+
})
131+
} else {
132+
await Promise.all([
133+
buildCore(),
114134
buildAllPlugin()
115-
})
116-
} else {
117-
buildCore()
118-
buildAllPlugin()
135+
])
136+
}
119137
}
138+
139+
main().catch((e) => {
140+
console.error(e)
141+
process.exit(1)
142+
})
143+

build/css.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const {spawn} = require('child_process')
55
const args = process.argv.slice(2)
66
fs.readdir(path.join(__dirname, '../src/themes'), (err, files) => {
77
if (err) {
8-
console.log('err', err)
9-
return
8+
console.error('err', err)
9+
process.exit(1)
1010
}
1111
files.map(async (file) => {
1212
if (/\.styl/g.test(file)) {
@@ -31,11 +31,17 @@ fs.readdir(path.join(__dirname, '../src/themes'), (err, files) => {
3131
});
3232

3333
stylusCMD.on('close', (code) => {
34-
console.log(`[Stylus Build ] child process exited with code ${code}`);
34+
const message = `[Stylus Build ] child process exited with code ${code}`
35+
36+
if (code !== 0) {
37+
console.error(message);
38+
process.exit(code)
39+
}
40+
console.log(message);
3541
});
3642
} else {
3743
return
3844
}
3945

4046
})
41-
})
47+
})

build/mincss.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ files.forEach(file => {
88
file = path.resolve('lib/themes', file)
99
cssnano(fs.readFileSync(file)).then(result => {
1010
fs.writeFileSync(file, result.css)
11+
}).catch(e => {
12+
console.error(e)
13+
process.exit(1)
1114
})
1215
})

build/ssr.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ rollup
2424
var dest = 'packages/docsify-server-renderer/build.js'
2525

2626
console.log(dest)
27-
bundle.write({
27+
return bundle.write({
2828
format: 'cjs',
2929
file: dest
3030
})
3131
})
3232
.catch(function (err) {
3333
console.error(err)
34+
process.exit(1)
3435
})

cypress/fixtures/tpl/docs.index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<meta name="description" content="A magical documentation generator." />
1717
<meta
1818
name="viewport"
19-
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
19+
content="width=device-width, initial-scale=1.0, minimum-scale=1.0"
2020
/>
2121
<link rel="stylesheet" href="lib/themes/vue.css" title="vue" />
2222
<link rel="stylesheet" href="lib/themes/dark.css" title="dark" disabled />

docs/_media/example-with-yaml.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
author: John Smith
3+
date: 2020-1-1
4+
---
5+
6+
> This is from the `example.md`

docs/configuration.md

+31-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Configuration
22

3-
You can configure the `window.$docsify`.
3+
You can configure Docsify by defining `window.$docsify` as an object:
44

55
```html
66
<script>
@@ -12,6 +12,24 @@ You can configure the `window.$docsify`.
1212
</script>
1313
```
1414

15+
The config can also be defined as a function, in which case the first arg is the Docsify `vm` instance. The function should return a config object. This can be useful for referencing `vm` in places like the markdown configuration:
16+
17+
```html
18+
<script>
19+
window.$docsify = function(vm) {
20+
return {
21+
markdown: {
22+
renderer: {
23+
code(code, lang) {
24+
// ... use `vm` ...
25+
},
26+
},
27+
},
28+
};
29+
};
30+
</script>
31+
```
32+
1533
## el
1634

1735
- Type: `String`
@@ -144,6 +162,16 @@ window.$docsify = {
144162
};
145163
```
146164

165+
If you have a link to the homepage in the sidebar and want it to be shown as active when accessing the root url, make sure to update your sidebar accordingly:
166+
167+
```markdown
168+
- Sidebar
169+
- [Home](/)
170+
- [Another page](another.md)
171+
```
172+
173+
For more details, see [#1131](https://github.com/docsifyjs/docsify/issues/1131).
174+
147175
## basePath
148176

149177
- Type: `String`
@@ -446,11 +474,11 @@ window.$docsify = {
446474
- type: `String`
447475
- default: `noopener`
448476

449-
Default `'noopener'` (no opener) prevents the newly opened external page (when [externalLinkTarget](#externallinktarget) is `'_blank'`) from having the ability to control our page. No `rel` is set when its not `'_blank'`.
477+
Default `'noopener'` (no opener) prevents the newly opened external page (when [externalLinkTarget](#externallinktarget) is `'_blank'`) from having the ability to control our page. No `rel` is set when its not `'_blank'`. See [this post](https://mathiasbynens.github.io/rel-noopener/) for more information about why you may want to use this option.
450478

451479
```js
452480
window.$docsify = {
453-
externalLinkTarget: '', // default: 'noopener'
481+
externalLinkRel: '', // default: 'noopener'
454482
};
455483
```
456484

docs/cover.md

-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ Set `coverpage` to **true**, and create a `_coverpage.md`:
3434
[Get Started](#docsify)
3535
```
3636

37-
!> A document site can have only one coverpage!
38-
3937
## Custom background
4038

4139
The background color is generated randomly by default. You can customize the background color or a background image:

docs/embed-files.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,20 @@ You will get it
3939

4040
[filename](_media/example.md ':include :type=code')
4141

42+
## Markdown with YAML Front Matter
43+
44+
When using Markdown, YAML front matter will be stripped from the rendered content. The attributes cannot be used in this case.
45+
46+
```markdown
47+
[filename](_media/example-with-yaml.md ':include')
48+
```
49+
50+
You will get just the content
51+
52+
[filename](_media/example-with-yaml.md ':include')
53+
4254
## Embedded code fragments
55+
4356
Sometimes you don't want to embed a whole file. Maybe because you need just a few lines but you want to compile and test the file in CI.
4457

4558
```markdown
@@ -53,7 +66,6 @@ Example:
5366

5467
[filename](_media/example.js ':include :type=code :fragment=demo')
5568

56-
5769
## Tag attribute
5870

5971
If you embed the file as `iframe`, `audio` and `video`, then you may need to set the attributes of these tags.

docs/helpers.md

+8
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
6565
[link](/demo ':disabled')
6666
```
6767

68+
## Cross-Origin link
69+
70+
Only when you both set the `routerMode: 'history'` and `externalLinkTarget: '_self'`, you need add this configuration for those Cross-Origin links.
71+
72+
```md
73+
[example.com](https://example.com/ ':crossorgin')
74+
```
75+
6876
## Github Task Lists
6977

7078
```md

0 commit comments

Comments
 (0)