Skip to content

Commit

Permalink
Merge branch 'develop' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records authored Aug 4, 2020
2 parents 190de35 + 750663e commit b896d63
Show file tree
Hide file tree
Showing 19 changed files with 141 additions and 69 deletions.
9 changes: 1 addition & 8 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [ ] Refactor
- [ ] Docs
- [ ] Build-related changes
- [ ] Repo settings
- [ ] Other, please describe:

If changing the UI of default theme, please provide the **before/after** screenshot:
Expand Down Expand Up @@ -44,11 +45,3 @@ If adding a **new feature**, the PR's description includes:
- [ ] Related tests have been updated

To avoid wasting your time, it's best to open a **feature request issue** first and wait for approval before working on it.


**Other information:**

---

* [ ] DO NOT include files inside `lib` directory.

10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
.DS_Store
.idea
node_modules
themes/
lib/
cypress/integration/examples
cypress/fixtures/docs
/themes/
/lib/
/cypress/integration/examples
/cypress/fixtures/docs

# exceptions
!.gitkeep
!.gitkeep
4 changes: 2 additions & 2 deletions docs/cdn.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Alternatively, use [compressed files](#compressed-file).

## Other CDN

- http://www.bootcdn.cn/docsify
- https://www.bootcdn.cn/docsify/
- https://cdn.jsdelivr.net/npm/docsify/
- https://cdnjs.com/libraries/docsify

- https://unpkg.com/browse/docsify/
32 changes: 16 additions & 16 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ You can configure Docsify by defining `window.$docsify` as an object:
</script>
```

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:
The config can also be defined as a function, in which case the first argument 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:

```html
<script>
Expand All @@ -35,7 +35,7 @@ The config can also be defined as a function, in which case the first arg is the
- Type: `String`
- Default: `#app`

The DOM element to be mounted on initialization. It can be a CSS selector string or an actual HTMLElement.
The DOM element to be mounted on initialization. It can be a CSS selector string or an actual [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement).

```js
window.$docsify = {
Expand All @@ -48,7 +48,7 @@ window.$docsify = {
- Type: `String`
- Default: `null`

Configure the repository url or a string of `username/repo` can add the [GitHub Corner](http://tholman.com/github-corners/) widget in the top right corner of the site.
Configure the repository url, or a string of `username/repo` can add the [GitHub Corner](http://tholman.com/github-corners/) widget in the top right corner of the site.

```js
window.$docsify = {
Expand Down Expand Up @@ -76,7 +76,7 @@ window.$docsify = {
- Type: `Boolean|String`
- Default: `false`

Loads navbar from the Markdown file `_navbar.md` if **true**, or else from the path specified.
Loads navbar from the Markdown file `_navbar.md` if **true**, else loads it from the path specified.

```js
window.$docsify = {
Expand All @@ -93,7 +93,7 @@ window.$docsify = {
- Type: `Boolean|String`
- Default: `false`

Loads sidebar from the Markdown file `_sidebar.md` if **true**, or else from the path specified.
Loads sidebar from the Markdown file `_sidebar.md` if **true**, else loads it from the path specified.

```js
window.$docsify = {
Expand All @@ -110,7 +110,7 @@ window.$docsify = {
- Type : `Boolean`
- Default: `true`

This option will completely hide your sidebar and wont render any content of the side even .
This option will completely hide your sidebar and won't render any content on the side.

```js
window.$docsify = {
Expand Down Expand Up @@ -149,7 +149,7 @@ window.$docsify = {
- Type: `String`
- Default: `README.md`

`README.md` in your docs folder will be treated as homepage for your website, but sometimes you may need to serve another file as your homepage.
`README.md` in your docs folder will be treated as the homepage for your website, but sometimes you may need to serve another file as your homepage.

```js
window.$docsify = {
Expand Down Expand Up @@ -196,7 +196,7 @@ window.$docsify = {
- Type: `Boolean`
- Default: `false`

If **true** links are relative to the current context.
If **true**, links are relative to the current context.

For example, the directory structure is as follows:

Expand Down Expand Up @@ -260,7 +260,7 @@ window.$docsify = {

- Type: `String`

Website logo as it appears in the sidebar, you can resize by CSS.
Website logo as it appears in the sidebar. You can resize it by using CSS.

```js
window.$docsify = {
Expand Down Expand Up @@ -367,7 +367,7 @@ window.$docsify = {

- type: `Boolean`

If `loadSidebar` and `autoHeader` are both enabled, for each link in `_sidebar.md`, prepend a header to the page before converting it to html. Compare [#78](https://github.com/docsifyjs/docsify/issues/78).
If `loadSidebar` and `autoHeader` are both enabled, for each link in `_sidebar.md`, prepend a header to the page before converting it to HTML. Compare [#78](https://github.com/docsifyjs/docsify/issues/78).

```js
window.$docsify = {
Expand Down Expand Up @@ -474,7 +474,7 @@ window.$docsify = {
- type: `String`
- default: `noopener`

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.
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 it's not `'_blank'`. See [this post](https://mathiasbynens.github.io/rel-noopener/) for more information about why you may want to use this option.

```js
window.$docsify = {
Expand Down Expand Up @@ -557,13 +557,13 @@ window.$docsify = {

- type: `Array<string>`

List of languages that will fallback to the default language when a page is request and didn't exists for the given local.
List of languages that will fallback to the default language when a page is requested and it doesn't exist for the given local.

Example:

- try to fetch the page of `/de/overview`. If this page exists, it'll be displayed
- then try to fetch the default page `/overview` (depending on the default language). If this page exists, it'll be displayed
- then display 404 page.
- try to fetch the page of `/de/overview`. If this page exists, it'll be displayed.
- then try to fetch the default page `/overview` (depending on the default language). If this page exists, it'll be displayed.
- then display the 404 page.

```js
window.$docsify = {
Expand All @@ -583,7 +583,7 @@ window.$docsify = {
};
```

Load the customised path of the 404 page:
Load the customized path of the 404 page:

```js
window.$docsify = {
Expand Down
6 changes: 3 additions & 3 deletions docs/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

docsify extends Markdown syntax to make your documents more readable.

> Note: For the special code syntax cases, you'd better put them within a code backticks to avoid any conflicting from configurations or emojis.
> Note: For the special code syntax cases, you'd better put them within a code backticks to avoid any conflicting from configurations or emojis.
## important content

Expand Down Expand Up @@ -70,7 +70,7 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
Only when you both set the `routerMode: 'history'` and `externalLinkTarget: '_self'`, you need add this configuration for those Cross-Origin links.

```md
[example.com](https://example.com/ ':crossorgin')
[example.com](https://example.com/ ':crossorgin')
```

## Github Task Lists
Expand Down Expand Up @@ -124,7 +124,7 @@ Only when you both set the `routerMode: 'history'` and `externalLinkTarget: '_se
## Customise ID for headings

```md
### 你好,世界! :id=hello-world
### Hello, world! :id=hello-world
```

## Markdown in html tag
Expand Down
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
'/zh-cn/(.*)': 'https://cdn.jsdelivr.net/gh/docsifyjs/docs-zh@master/$1',
'/de-de/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-de/master/$1',
'/ru-ru/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-ru/master/$1',
'/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1'
'/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1',
'/write-a-plugin': 'https://raw.githubusercontent.com/docsifyjs/docsify/master/docs/write-a-plugin.md'
},
auto2top: true,
coverpage: true,
Expand Down Expand Up @@ -62,7 +63,6 @@
'/': 'Search'
}
},
formatUpdated: '{MM}/{DD} {HH}:{mm}',
plugins: [
function (hook, vm) {
hook.beforeEach(function (html) {
Expand Down
10 changes: 5 additions & 5 deletions docs/more-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,24 @@ A custom sidebar can also automatically generate a table of contents by setting

## Ignoring Subheaders

When `subMaxLevel` is set, each header is automatically added to the table of contents by default. If you want to ignore a specific header, add `{docsify-ignore}` to it.
When `subMaxLevel` is set, each header is automatically added to the table of contents by default. If you want to ignore a specific header, add `<!-- {docsify-ignore} -->` to it.

```markdown
# Getting Started

## Header {docsify-ignore}
## Header <!-- {docsify-ignore} -->

This header won't appear in the sidebar table of contents.
```

To ignore all headers on a specific page, you can use `{docsify-ignore-all}` on the first header of the page.
To ignore all headers on a specific page, you can use `<!-- {docsify-ignore-all} -->` on the first header of the page.

```markdown
# Getting Started {docsify-ignore-all}
# Getting Started <!-- {docsify-ignore-all} -->

## Header

This header won't appear in the sidebar table of contents.
```

Both `{docsify-ignore}` and `{docsify-ignore-all}` will not be rendered on the page when used.
Both `<!-- {docsify-ignore} -->` and `<!-- {docsify-ignore-all} -->` will not be rendered on the page when used.
11 changes: 11 additions & 0 deletions docs/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ By default, the hyperlink on the current page is recognized and the content is s
// To avoid search index collision
// between multiple websites under the same domain
namespace: 'website-1',
// Use different indexes for path prefixes (namespaces).
// NOTE: Only works in 'auto' mode.
//
// When initialiazing an index, we look for the first path from the sidebar.
// If it matches the prefix from the list, we switch to the corresponding index.
pathNamespaces: ['/zh-cn', '/ru-ru', '/ru-ru/v1'],
// You can provide a regexp to match prefixes. In this case,
// the matching substring will be used to identify the index
pathNamespaces: /^(\/(zh-cn|ru-ru))?(\/(v1|v2))?/
}
}
</script>
Expand Down
16 changes: 9 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<link rel="stylesheet" href="/themes/vue.css" title="vue">
<link rel="stylesheet" href="/themes/dark.css" title="dark" disabled>
<link rel="stylesheet" href="/themes/buble.css" title="buble" disabled>
<link rel="stylesheet" href="/themes/pure.css" title="pure" disabled>
<style>
nav.app-nav li ul {
min-width: 100px;
Expand All @@ -27,7 +28,8 @@
'/zh-cn/(.*)': 'https://cdn.jsdelivr.net/gh/docsifyjs/docs-zh@master/$1',
'/de-de/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-de/master/$1',
'/ru-ru/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-ru/master/$1',
'/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1'
'/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1',
'/write-a-plugin': 'https://raw.githubusercontent.com/docsifyjs/docsify/master/docs/write-a-plugin.md'
},
auto2top: true,
basePath: '/docs/',
Expand All @@ -50,9 +52,9 @@
'/de-de/': 'Suche',
'/zh-cn/': '搜索',
'/': 'Search'
}
},
pathNamespaces: ['/zh-cn', '/de-de', '/ru-ru', '/es']
},
formatUpdated: '{MM}/{DD} {HH}:{mm}',
plugins: [
function (hook, vm) {
hook.beforeEach(function (html) {
Expand All @@ -68,7 +70,6 @@
url = 'https://github.com/docsifyjs/docsify/blob/master/docs/' + vm.route.file
}
var editHtml = '[:memo: Edit Document](' + url + ')\n'

return editHtml
+ html
+ '\n\n----\n\n'
Expand All @@ -82,9 +83,10 @@
<script src="/lib/plugins/search.js"></script>
<script src="/lib/plugins/emoji.js"></script>
<script src="/lib/plugins/front-matter.js"></script>
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-markdown.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-nginx.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-bash.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-markdown.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-nginx.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-php.min.js"></script>
</body>

</html>
6 changes: 3 additions & 3 deletions packages/docsify-server-renderer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var readFileSync = require('fs').readFileSync

// init
var renderer = new Renderer({
template: readFileSync('./docs/index.template.html', 'utf-8').,
template: readFileSync('./docs/index.template.html', 'utf-8'),
config: {
name: 'docsify',
repo: 'docsifyjs/docsify'
Expand All @@ -35,12 +35,12 @@ renderer.renderToString(url)
<meta charset="UTF-8">
<title>docsify</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//unpkg.com/docsify/themes/buble.css" title="buble" disabled>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/vue.css" title="vue">
</head>
<body>
<!--inject-app-->
<!--inject-config-->
<script src="//unpkg.com/docsify/lib/docsify.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.js"></script>
</body>
</html>
```
7 changes: 5 additions & 2 deletions src/core/event/scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ function highlight(path) {
const isInView =
active.offsetTop >= wrap.scrollTop && cur <= wrap.scrollTop + height;
const notThan = cur - curOffset < height;
const top = isInView ? wrap.scrollTop : notThan ? curOffset : cur - height;

sidebar.scrollTop = top;
sidebar.scrollTop = isInView
? wrap.scrollTop
: notThan
? curOffset
: cur - height;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/core/event/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export function getAndActive(router, el, isParent, autoTitle) {
const href = a.getAttribute('href');
const node = isParent ? a.parentNode : a;

a.title = a.innerText;

if (hash.indexOf(href) === 0 && !target) {
target = a;
dom.toggleClass(node, 'add', 'active');
Expand Down
8 changes: 4 additions & 4 deletions src/core/render/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,14 @@ export class Compiler {
let { str, config } = getAndRemoveConfig(text);
const nextToc = { level, title: str };

if (/{docsify-ignore}/g.test(str)) {
str = str.replace('{docsify-ignore}', '');
if (/<!-- {docsify-ignore} -->/g.test(str)) {
str = str.replace('<!-- {docsify-ignore} -->', '');
nextToc.title = str;
nextToc.ignoreSubHeading = true;
}

if (/{docsify-ignore-all}/g.test(str)) {
str = str.replace('{docsify-ignore-all}', '');
if (/<!-- {docsify-ignore-all} -->/g.test(str)) {
str = str.replace('<!-- {docsify-ignore-all} -->', '');
nextToc.title = str;
nextToc.ignoreAllSubs = true;
}
Expand Down
Loading

0 comments on commit b896d63

Please sign in to comment.