mirror of
https://github.com/wahyd4/docsify.git
synced 2026-08-09 13:26:34 +10:00
Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27dc7038e3 | ||
|
|
0bd5c8b020 | ||
|
|
044a5ec2b8 | ||
|
|
b15eccfac0 | ||
|
|
4e0298088b | ||
|
|
09616dec06 | ||
|
|
f74b53f53e | ||
|
|
bba44fb536 | ||
|
|
270fa6cb41 | ||
|
|
24e61f5e2f | ||
|
|
ca8ae50717 | ||
|
|
31654f12ec | ||
|
|
99dbaa3050 |
@@ -1,2 +0,0 @@
|
||||
<!-- Love docsify? Please consider supporting our collective:
|
||||
👉 https://opencollective.com/docsify/donate -->
|
||||
@@ -0,0 +1,40 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
|
||||
---
|
||||
<!-- Please don't delete this template or we'll close your issue -->
|
||||
<!-- Please use English language -->
|
||||
<!-- Before creating an issue please make sure you are using the latest version of Docsify. -->
|
||||
<!-- Please ask questions on StackOverflow: https://stackoverflow.com/questions/ask?tags=docsify -->
|
||||
|
||||
## Bug Report
|
||||
|
||||
#### Steps to reproduce
|
||||
|
||||
|
||||
|
||||
#### What is current behaviour
|
||||
|
||||
|
||||
|
||||
#### What is the expected behaviour
|
||||
|
||||
---
|
||||
|
||||
- [ ] Bug does still occur when all/other plugins are disabled?
|
||||
|
||||
<!-- Please type in your environment -->
|
||||
Environment:
|
||||
|
||||
```
|
||||
operating system:
|
||||
npm version:
|
||||
nodejs version:
|
||||
docsify version:
|
||||
docsify plugins:
|
||||
browser:
|
||||
```
|
||||
|
||||
<!-- Love docsify? Please consider supporting our collective:
|
||||
👉 https://opencollective.com/docsify/donate -->
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
|
||||
---
|
||||
<!-- Please don't delete this template or we'll close your issue -->
|
||||
<!-- Please use English language -->
|
||||
<!-- Before creating an issue please make sure you are using the latest version of Docsify. -->
|
||||
<!-- Please ask questions on StackOverflow 👉 https://stackoverflow.com/questions/ask?tags=docsify -->
|
||||
|
||||
## Feature request
|
||||
|
||||
#### What problem does this feature solve?
|
||||
|
||||
|
||||
|
||||
#### What does the proposed API look like?
|
||||
|
||||
|
||||
|
||||
#### How should this be implemented in your opinion?
|
||||
|
||||
|
||||
|
||||
#### Are you willing to work on this yourself?
|
||||
@@ -1,5 +1,54 @@
|
||||
Please makes sure these boxes are checked before submitting your PR, thank you!
|
||||
<!-- Please use English language -->
|
||||
<!-- Please don't delete this template -->
|
||||
|
||||
<!-- PULL REQUEST TEMPLATE -->
|
||||
<!-- (Update "[ ]" to "[x]" to check a box) -->
|
||||
|
||||
**Summary**
|
||||
|
||||
**What kind of change does this PR introduce?** (check at least one)
|
||||
|
||||
- [ ] Bugfix
|
||||
- [ ] Feature
|
||||
- [ ] Code style update
|
||||
- [ ] Refactor
|
||||
- [ ] Docs
|
||||
- [ ] Build-related changes
|
||||
- [ ] Other, please describe:
|
||||
|
||||
If changing the UI of default theme, please provide the **before/after** screenshot:
|
||||
|
||||
**Does this PR introduce a breaking change?** (check one)
|
||||
|
||||
- [ ] Yes
|
||||
- [ ] No
|
||||
|
||||
If yes, please describe the impact and migration path for existing applications:
|
||||
|
||||
**The PR fulfills these requirements:**
|
||||
|
||||
- [ ] When resolving a specific issue, it's referenced in the PR's title (e.g. `fix #xxx[,#xxx]`, where "xxx" is the issue number)
|
||||
|
||||
You have tested in the following browsers: (Providing a detailed version will be better.)
|
||||
|
||||
- [ ] Chrome
|
||||
- [ ] Firefox
|
||||
- [ ] Safari
|
||||
- [ ] Edge
|
||||
- [ ] IE
|
||||
|
||||
If adding a **new feature**, the PR's description includes:
|
||||
|
||||
- [ ] A convincing reason for adding this feature
|
||||
- [ ] Related documents have been updated
|
||||
- [ ] 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:**
|
||||
|
||||
---
|
||||
|
||||
* [ ] Make sure you are merging your commits to `master` branch.
|
||||
* [ ] Add some descriptions and refer relative issues for you PR.
|
||||
* [ ] DO NOT include files inside `lib` directory.
|
||||
|
||||
|
||||
@@ -150,6 +150,46 @@ window.$docsify = {
|
||||
};
|
||||
```
|
||||
|
||||
## relativePath
|
||||
|
||||
- Type: `Boolean`
|
||||
- Default: `false`
|
||||
|
||||
If **true** links are relative to the current context.
|
||||
|
||||
For example, the directory structure is as follows:
|
||||
|
||||
```text
|
||||
.
|
||||
└── docs
|
||||
├── README.md
|
||||
├── guide.md
|
||||
└── zh-cn
|
||||
├── README.md
|
||||
├── guide.md
|
||||
└── config
|
||||
└── example.md
|
||||
```
|
||||
|
||||
With relative path **enabled** and current URL `http://domain.com/zh-cn/README`, given links will resolve to:
|
||||
|
||||
```text
|
||||
guide.md => http://domain.com/zh-cn/guide
|
||||
config/example.md => http://domain.com/zh-cn/config/example
|
||||
../README.md => http://domain.com/README
|
||||
/README.md => http://domain.com/README
|
||||
```
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
// Relative path enabled
|
||||
relativePath: true,
|
||||
|
||||
// Relative path disabled (default value)
|
||||
relativePath: false
|
||||
};
|
||||
```
|
||||
|
||||
## coverpage
|
||||
|
||||
- Type: `Boolean|String|String[]|Object`
|
||||
|
||||
@@ -72,6 +72,16 @@ You can specify `alias` to avoid unnecessary fallback.
|
||||
|
||||
!> You can create a `README.md` file in a subdirectory to use it as the landing page for the route.
|
||||
|
||||
## Set Page Titles from Sidebar Selection
|
||||
|
||||
A page's `title` tag is generated from the _selected_ sidebar item name. For better SEO, you can customize the title by specifying a string after the filename.
|
||||
|
||||
```markdown
|
||||
<!-- docs/_sidebar.md -->
|
||||
* [Home](/)
|
||||
* [Guide](guide.md "The greatest guide in the world")
|
||||
```
|
||||
|
||||
## Table of Contents
|
||||
|
||||
Once you've created `_sidebar.md`, the sidebar content is automatically generated based on the headers in the markdown files.
|
||||
|
||||
@@ -79,7 +79,7 @@ window.$docsify = {
|
||||
function(hook, vm) {
|
||||
hook.beforeEach(function(html) {
|
||||
var url =
|
||||
'https://github.com/docsifyjs/docsify/blob/master/docs' +
|
||||
'https://github.com/docsifyjs/docsify/blob/master/docs/' +
|
||||
vm.route.file;
|
||||
var editHtml = '[📝 EDIT DOCUMENT](' + url + ')\n';
|
||||
|
||||
|
||||
+28
-12
@@ -21,48 +21,64 @@
|
||||
<script>
|
||||
window.$docsify = {
|
||||
alias: {
|
||||
'.*?/changelog': 'https://raw.githubusercontent.com/docsifyjs/docsify/master/CHANGELOG',
|
||||
'.*?/awesome': 'https://raw.githubusercontent.com/docsifyjs/awesome-docsify/master/README.md',
|
||||
'.*?/changelog': 'https://raw.githubusercontent.com/docsifyjs/docsify/master/CHANGELOG.md',
|
||||
'/.*/_navbar.md': '/_navbar.md',
|
||||
'/zh-cn/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-zh/master/$1',
|
||||
'/de-de/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-de/master/$1',
|
||||
'/ru/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-ru/master/$1',
|
||||
'/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1'
|
||||
},
|
||||
notFoundPage: '_404.html',
|
||||
auto2top: true,
|
||||
basePath: '/docs/',
|
||||
executeScript: true,
|
||||
loadNavbar: true,
|
||||
loadSidebar: true,
|
||||
coverpage: true,
|
||||
name: 'docsify',
|
||||
subMaxLevel: 2,
|
||||
executeScript: true,
|
||||
loadSidebar: true,
|
||||
loadNavbar: true,
|
||||
mergeNavbar: true,
|
||||
maxLevel: 4,
|
||||
subMaxLevel: 2,
|
||||
name: 'docsify',
|
||||
search: {
|
||||
noData: {
|
||||
'/de-de/': 'Keine Ergebnisse!',
|
||||
'/zh-cn/': '没有结果!',
|
||||
'/': 'No results!'
|
||||
},
|
||||
paths: 'auto',
|
||||
placeholder: {
|
||||
'/de-de/': 'Suche',
|
||||
'/zh-cn/': '搜索',
|
||||
'/': 'Search'
|
||||
}
|
||||
},
|
||||
formatUpdated: '{MM}/{DD} {HH}:{mm}',
|
||||
plugins: [
|
||||
function (hook, vm) {
|
||||
hook.beforeEach(function (html) {
|
||||
var url
|
||||
if (/githubusercontent\.com/.test(vm.route.file)) {
|
||||
url = vm.route.file
|
||||
.replace('raw.githubusercontent.com', 'github.com')
|
||||
.replace(/\/master/, '/blob/master')
|
||||
} else {
|
||||
url = 'https://github.com/docsifyjs/docsify/blob/master/' + vm.route.file
|
||||
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'
|
||||
+ 'Last modified {docsify-updated} '
|
||||
+ editHtml
|
||||
+ '<a href="https://docsify.js.org" target="_blank" style="color: inherit; font-weight: normal; text-decoration: none;">Powered by docsify</a>'
|
||||
})
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
</script>
|
||||
<script src="/lib/docsify.js"></script>
|
||||
<script src="/lib/plugins/search.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>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
+2
-1
@@ -25,7 +25,8 @@ export default function () {
|
||||
formatUpdated: '',
|
||||
externalLinkTarget: '_blank',
|
||||
routerMode: 'hash',
|
||||
noCompileLinks: []
|
||||
noCompileLinks: [],
|
||||
relativePath: false
|
||||
},
|
||||
window.$docsify
|
||||
)
|
||||
|
||||
@@ -3,7 +3,8 @@ import {
|
||||
isAbsolutePath,
|
||||
stringifyQuery,
|
||||
cleanPath,
|
||||
replaceSlug
|
||||
replaceSlug,
|
||||
resolvePath
|
||||
} from '../util'
|
||||
import {noop, merge} from '../../util/core'
|
||||
|
||||
@@ -73,9 +74,13 @@ export class History {
|
||||
if (local) {
|
||||
const idIndex = currentRoute.indexOf('?')
|
||||
path =
|
||||
(idIndex > 0 ? currentRoute.substr(0, idIndex) : currentRoute) + path
|
||||
(idIndex > 0 ? currentRoute.substring(0, idIndex) : currentRoute) + path
|
||||
}
|
||||
|
||||
if (this.config.relativePath && path.indexOf('/') !== 0) {
|
||||
const currentDir = currentRoute.substring(0, currentRoute.lastIndexOf('/') + 1)
|
||||
return cleanPath(resolvePath(currentDir + path))
|
||||
}
|
||||
return cleanPath('/' + path)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,20 @@ export const cleanPath = cached(path => {
|
||||
return path.replace(/^\/+/, '/').replace(/([^:])\/{2,}/g, '$1/')
|
||||
})
|
||||
|
||||
export const resolvePath = cached(path => {
|
||||
const segments = path.replace(/^\//, '').split('/')
|
||||
let resolved = []
|
||||
for (let i = 0, len = segments.length; i < len; i++) {
|
||||
const segment = segments[i]
|
||||
if (segment === '..') {
|
||||
resolved.pop()
|
||||
} else if (segment !== '.') {
|
||||
resolved.push(segment)
|
||||
}
|
||||
}
|
||||
return '/' + resolved.join('/')
|
||||
})
|
||||
|
||||
export function getPath(...args) {
|
||||
return cleanPath(args.join('/'))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/* eslint-env node, chai, mocha */
|
||||
require = require('esm')(module/*, options*/)
|
||||
const {expect} = require('chai')
|
||||
const {History} = require('../../src/core/router/history/base')
|
||||
|
||||
class MockHistory extends History {
|
||||
parse(path) {
|
||||
return {path}
|
||||
}
|
||||
}
|
||||
|
||||
describe('router/history/base', function () {
|
||||
describe('relativePath true', function () {
|
||||
var history
|
||||
|
||||
beforeEach(function () {
|
||||
history = new MockHistory({relativePath: true})
|
||||
})
|
||||
|
||||
it('toURL', function () {
|
||||
// WHEN
|
||||
const url = history.toURL('guide.md', {}, '/zh-ch/')
|
||||
|
||||
// THEN
|
||||
expect(url).equal('/zh-ch/guide')
|
||||
})
|
||||
|
||||
it('toURL with double dot', function () {
|
||||
// WHEN
|
||||
const url = history.toURL('../README.md', {}, '/zh-ch/')
|
||||
|
||||
// THEN
|
||||
expect(url).equal('/README')
|
||||
})
|
||||
|
||||
it('toURL child path', function () {
|
||||
// WHEN
|
||||
const url = history.toURL('config/example.md', {}, '/zh-ch/')
|
||||
|
||||
// THEN
|
||||
expect(url).equal('/zh-ch/config/example')
|
||||
})
|
||||
|
||||
it('toURL absolute path', function () {
|
||||
// WHEN
|
||||
const url = history.toURL('/README', {}, '/zh-ch/')
|
||||
|
||||
// THEN
|
||||
expect(url).equal('/README')
|
||||
})
|
||||
})
|
||||
|
||||
it('toURL without relative path', function () {
|
||||
const history = new MockHistory({relativePath: false})
|
||||
|
||||
// WHEN
|
||||
const url = history.toURL('README', {}, '/zh-ch/')
|
||||
|
||||
// THEN
|
||||
expect(url).equal('/README')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,30 @@
|
||||
/* eslint-env node, chai, mocha */
|
||||
require = require('esm')(module/*, options*/)
|
||||
const {expect} = require('chai')
|
||||
const {resolvePath} = require('../../src/core/router/util')
|
||||
|
||||
describe('router/util', function () {
|
||||
it('resolvePath', async function () {
|
||||
// WHEN
|
||||
const result = resolvePath('hello.md')
|
||||
|
||||
// THEN
|
||||
expect(result).equal('/hello.md')
|
||||
})
|
||||
|
||||
it('resolvePath with dot', async function () {
|
||||
// WHEN
|
||||
const result = resolvePath('./hello.md')
|
||||
|
||||
// THEN
|
||||
expect(result).equal('/hello.md')
|
||||
})
|
||||
|
||||
it('resolvePath with two dots', async function () {
|
||||
// WHEN
|
||||
const result = resolvePath('test/../hello.md')
|
||||
|
||||
// THEN
|
||||
expect(result).equal('/hello.md')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user