Skip to content

Commit 7f835b1

Browse files
Merge branch 'develop' into update-config
2 parents 96d5b19 + 26cb940 commit 7f835b1

34 files changed

+2122
-1655
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+
}

.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

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

+14-4
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ window.$docsify = {
144144
};
145145
```
146146

147+
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:
148+
149+
```markdown
150+
- Sidebar
151+
- [Home](/)
152+
- [Another page](another.md)
153+
```
154+
155+
For more details, see [#1131](https://github.com/docsifyjs/docsify/issues/1131).
156+
147157
## basePath
148158

149159
- Type: `String`
@@ -265,7 +275,7 @@ window.$docsify = {
265275
- Type: `String`
266276
- Default: `window.location.pathname`
267277

268-
The name of the link.
278+
The URL that the website `name` links to.
269279

270280
```js
271281
window.$docsify = {
@@ -446,11 +456,11 @@ window.$docsify = {
446456
- type: `String`
447457
- default: `noopener`
448458

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'`.
459+
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.
450460

451461
```js
452462
window.$docsify = {
453-
externalLinkTarget: '', // default: 'noopener'
463+
externalLinkRel: '', // default: 'noopener'
454464
};
455465
```
456466

@@ -587,4 +597,4 @@ Adds a space on top when scrolling content page to reach the selected section. T
587597
window.$docsify = {
588598
topMargin: 90, // default: 0
589599
};
590-
```
600+
```

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

docs/index.html

+8-10
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
1010
<meta name="keywords" content="doc,docs,documentation,gitbook,creator,generator,github,jekyll,github-pages">
1111
<meta name="description" content="A magical documentation generator.">
12-
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
12+
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
1313
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/lib/themes/vue.css" title="vue">
1414
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/lib/themes/dark.css" title="dark" disabled>
1515
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/lib/themes/buble.css" title="buble" disabled>
1616
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/lib/themes/pure.css" title="pure" disabled>
17-
17+
1818
<script src="//cdn.jsdelivr.net/npm/docsify-plugin-codefund/index.js"></script>
19-
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/[email protected]/dist/style.css"/>
19+
2020
<style>
2121
nav.app-nav li ul {
2222
min-width: 100px;
@@ -32,7 +32,7 @@
3232
'.*?/awesome': 'https://raw.githubusercontent.com/docsifyjs/awesome-docsify/master/README.md',
3333
'.*?/changelog': 'https://raw.githubusercontent.com/docsifyjs/docsify/master/CHANGELOG.md',
3434
'/.*/_navbar.md': '/_navbar.md',
35-
'/zh-cn/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-zh/master/$1',
35+
'/zh-cn/(.*)': 'https://cdn.jsdelivr.net/gh/docsifyjs/docs-zh@master/$1',
3636
'/de-de/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-de/master/$1',
3737
'/ru/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-ru/master/$1',
3838
'/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1'
@@ -64,11 +64,6 @@
6464
'/': 'Search'
6565
}
6666
},
67-
darkMode: {
68-
light: {
69-
toggleBtnBg: '#42b983'
70-
}
71-
},
7267
formatUpdated: '{MM}/{DD} {HH}:{mm}',
7368
plugins: [
7469
function (hook, vm) {
@@ -77,6 +72,10 @@
7772
url = vm.route.file
7873
.replace('raw.githubusercontent.com', 'github.com')
7974
.replace(/\/master/, '/blob/master')
75+
} else if (/jsdelivr\.net/.test(vm.route.file)) {
76+
url = vm.route.file
77+
.replace('cdn.jsdelivr.net/gh', 'github.com')
78+
.replace('@master', '/blob/master')
8079
} else {
8180
url = 'https://github.com/docsifyjs/docsify/blob/master/docs/' + vm.route.file
8281
}
@@ -99,7 +98,6 @@
9998
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-bash.min.js"></script>
10099
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-markdown.min.js"></script>
101100
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-nginx.min.js"></script>
102-
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.js"></script>
103101
<script>
104102
((window.gitter = {}).chat = {}).options = {
105103
room: 'docsifyjs/Lobby'

docs/ssr.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ You can provide a template for entire page's HTML. such as
6868
<head>
6969
<meta charset="UTF-8">
7070
<title>docsify</title>
71-
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
71+
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
7272
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/vue.css" title="vue">
7373
</head>
7474
<body>

index.html

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
'.*?/awesome': 'https://raw.githubusercontent.com/docsifyjs/awesome-docsify/master/README.md',
2525
'.*?/changelog': 'https://raw.githubusercontent.com/docsifyjs/docsify/master/CHANGELOG.md',
2626
'/.*/_navbar.md': '/_navbar.md',
27-
'/zh-cn/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-zh/master/$1',
27+
'/zh-cn/(.*)': 'https://cdn.jsdelivr.net/gh/docsifyjs/docs-zh@master/$1',
2828
'/de-de/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-de/master/$1',
2929
'/ru/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-ru/master/$1',
3030
'/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1'
@@ -60,6 +60,10 @@
6060
url = vm.route.file
6161
.replace('raw.githubusercontent.com', 'github.com')
6262
.replace(/\/master/, '/blob/master')
63+
} else if (/jsdelivr\.net/.test(vm.route.file)) {
64+
url = vm.route.file
65+
.replace('cdn.jsdelivr.net/gh', 'github.com')
66+
.replace('@master', '/blob/master')
6367
} else {
6468
url = 'https://github.com/docsifyjs/docsify/blob/master/docs/' + vm.route.file
6569
}
@@ -76,6 +80,8 @@
7680
</script>
7781
<script src="/lib/docsify.js"></script>
7882
<script src="/lib/plugins/search.js"></script>
83+
<script src="/lib/plugins/emoji.js"></script>
84+
<script src="/lib/plugins/front-matter.js"></script>
7985
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
8086
<script src="//unpkg.com/prismjs/components/prism-markdown.min.js"></script>
8187
<script src="//unpkg.com/prismjs/components/prism-nginx.min.js"></script>

packages/docsify-server-renderer/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ renderer.renderToString(url)
3434
<head>
3535
<meta charset="UTF-8">
3636
<title>docsify</title>
37-
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
37+
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
3838
<link rel="stylesheet" href="//unpkg.com/docsify/themes/buble.css" title="buble" disabled>
3939
</head>
4040
<body>

packages/docsify-server-renderer/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { readFileSync } from 'fs';
22
import { resolve, basename } from 'path';
33
import resolvePathname from 'resolve-pathname';
4+
import fetch from 'node-fetch';
5+
import debug from 'debug';
46
import { AbstractHistory } from '../../src/core/router/history/abstract';
57
import { Compiler } from '../../src/core/render/compiler';
68
import { isAbsolutePath } from '../../src/core/router/util';
79
import * as tpl from '../../src/core/render/tpl';
810
import { prerenderEmbed } from '../../src/core/render/embed';
9-
import fetch from 'node-fetch';
10-
import debug from 'debug';
1111

1212
function cwd(...args) {
1313
return resolve(process.cwd(), ...args);

server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if (isSSR) {
1111
<head>
1212
<meta charset="UTF-8">
1313
<title>docsify</title>
14-
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
14+
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
1515
<link rel="stylesheet" href="/themes/vue.css" title="vue">
1616
</head>
1717
<body>

src/core/config.js

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default function() {
3232
externalLinkRel: 'noopener',
3333
routerMode: 'hash',
3434
noCompileLinks: [],
35+
crossOriginLinks: [],
3536
relativePath: false,
3637
topMargin: 0,
3738
},

src/core/event/scroll.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import Tweezer from 'tweezer.js';
12
import { isMobile } from '../util/env';
23
import * as dom from '../util/dom';
4+
import { removeParams } from '../router/util';
35
import config from '../config';
4-
import Tweezer from 'tweezer.js';
56

67
const nav = {};
78
let hoverOver = false;
@@ -59,8 +60,7 @@ function highlight(path) {
5960
return;
6061
}
6162

62-
const li =
63-
nav[getNavKey(decodeURIComponent(path), last.getAttribute('data-id'))];
63+
const li = nav[getNavKey(path, last.getAttribute('data-id'))];
6464

6565
if (!li || li === active) {
6666
return;
@@ -86,7 +86,7 @@ function highlight(path) {
8686
}
8787

8888
function getNavKey(path, id) {
89-
return `${path}?id=${id}`;
89+
return `${decodeURIComponent(path)}?id=${decodeURIComponent(id)}`;
9090
}
9191

9292
export function scrollActiveSidebar(router) {
@@ -127,7 +127,7 @@ export function scrollActiveSidebar(router) {
127127
return;
128128
}
129129

130-
const path = router.getCurrentPath();
130+
const path = removeParams(router.getCurrentPath());
131131
dom.off('scroll', () => highlight(path));
132132
dom.on('scroll', () => highlight(path));
133133
dom.on(sidebar, 'mouseover', () => {

src/core/event/sidebar.js

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export function collapse(el) {
3939
if (
4040
target.nodeName === 'A' &&
4141
target.nextSibling &&
42+
target.nextSibling.classList &&
4243
target.nextSibling.classList.contains('app-sub-sidebar')
4344
) {
4445
dom.toggleClass(target.parentNode, 'collapse');

src/core/global-api.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import prism from 'prismjs';
2+
import marked from 'marked';
13
import * as util from './util';
24
import * as dom from './util/dom';
35
import { Compiler } from './render/compiler';
46
import { slugify } from './render/slugify';
57
import { get } from './fetch/ajax';
6-
import prism from 'prismjs';
7-
import marked from 'marked';
88

99
export default function() {
1010
window.Docsify = {

src/core/render/compiler.js

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import marked from 'marked';
12
import { isAbsolutePath, getPath, getParentPath } from '../router/util';
23
import { isFn, merge, cached, isPrimitive } from '../util/core';
34
import { tree as treeTpl } from './tpl';
@@ -11,7 +12,6 @@ import { paragraphCompiler } from './compiler/paragraph';
1112
import { taskListCompiler } from './compiler/taskList';
1213
import { taskListItemCompiler } from './compiler/taskListItem';
1314
import { linkCompiler } from './compiler/link';
14-
import marked from 'marked';
1515

1616
const cachedLinks = {};
1717

@@ -121,6 +121,21 @@ export class Compiler {
121121
};
122122
}
123123

124+
/**
125+
* Pulls content from file and renders inline on the page as a embedded item.
126+
*
127+
* This allows you to embed different file types on the returned
128+
* page.
129+
* The basic format is:
130+
* ```
131+
* [filename](_media/example.md ':include')
132+
* ```
133+
*
134+
* @param {string} href The href to the file to embed in the page.
135+
* @param {string} title Title of the link used to make the embed.
136+
*
137+
* @return {type} Return value description.
138+
*/
124139
compileEmbed(href, title) {
125140
const { str, config } = getAndRemoveConfig(title);
126141
let embed;
@@ -178,7 +193,7 @@ export class Compiler {
178193

179194
_initRenderer() {
180195
const renderer = new marked.Renderer();
181-
const { linkTarget, router, contentBase } = this;
196+
const { linkTarget, linkRel, router, contentBase } = this;
182197
const _self = this;
183198
const origin = {};
184199

@@ -218,6 +233,7 @@ export class Compiler {
218233
renderer,
219234
router,
220235
linkTarget,
236+
linkRel,
221237
compilerClass: _self,
222238
});
223239
origin.paragraph = paragraphCompiler({ renderer });

src/core/render/compiler/image.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const imageCompiler = ({ renderer, contentBase, router }) =>
2222
if (height) {
2323
attrs.push(`width="${width}" height="${height}"`);
2424
} else {
25-
attrs.push(`width="${width}" height="${width}"`);
25+
attrs.push(`width="${width}"`);
2626
}
2727
}
2828

0 commit comments

Comments
 (0)