mirror of
https://github.com/wahyd4/docsify.git
synced 2026-08-10 05:48:18 +10:00
Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27dc7038e3 | ||
|
|
0bd5c8b020 | ||
|
|
044a5ec2b8 | ||
|
|
b15eccfac0 | ||
|
|
4e0298088b | ||
|
|
09616dec06 | ||
|
|
f74b53f53e | ||
|
|
bba44fb536 | ||
|
|
270fa6cb41 | ||
|
|
24e61f5e2f | ||
|
|
ca8ae50717 | ||
|
|
31654f12ec | ||
|
|
d80aa2189b | ||
|
|
21cde83949 | ||
|
|
c1d4961a64 | ||
|
|
d5910bd1f9 | ||
|
|
a35531967a | ||
|
|
11ea1f8d12 | ||
|
|
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.
|
* [ ] 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
|
## coverpage
|
||||||
|
|
||||||
- Type: `Boolean|String|String[]|Object`
|
- Type: `Boolean|String|String[]|Object`
|
||||||
|
|||||||
@@ -87,3 +87,45 @@ When using the HTML5 router, you need to set up redirect rules that redirect all
|
|||||||
```sh
|
```sh
|
||||||
/* /index.html 200
|
/* /index.html 200
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## AWS Amplify
|
||||||
|
|
||||||
|
1. Set the routerMode in the Docsify project `index.html` to *history* mode.
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script>
|
||||||
|
window.$docsify = {
|
||||||
|
loadSidebar: true,
|
||||||
|
routerMode: 'history'
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Login to your [AWS Console](https://aws.amazon.com).
|
||||||
|
3. Go to the [AWS Amplify Dashboard](https://aws.amazon.com/amplify).
|
||||||
|
4. Choose the **Deploy** route to setup your project.
|
||||||
|
5. When prompted, keep the build settings empty if you're serving your docs within the root directory. If you're serving your docs from a different directory, customise your amplify.yml
|
||||||
|
|
||||||
|
```yml
|
||||||
|
version: 0.1
|
||||||
|
frontend:
|
||||||
|
phases:
|
||||||
|
build:
|
||||||
|
commands:
|
||||||
|
- echo "Nothing to build"
|
||||||
|
artifacts:
|
||||||
|
baseDirectory: /docs
|
||||||
|
files:
|
||||||
|
- '**/*'
|
||||||
|
cache:
|
||||||
|
paths: []
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
6. Add the following Redirect rules in their displayed order.
|
||||||
|
|
||||||
|
| Source address | Target address | Type |
|
||||||
|
|----------------|----------------|---------------|
|
||||||
|
| /<*>.md | /<*>.md | 200 (Rewrite) |
|
||||||
|
| /<*> | /index.html | 200 (Rewrite) |
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
!> 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
|
## Table of Contents
|
||||||
|
|
||||||
Once you've created `_sidebar.md`, the sidebar content is automatically generated based on the headers in the markdown files.
|
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) {
|
function(hook, vm) {
|
||||||
hook.beforeEach(function(html) {
|
hook.beforeEach(function(html) {
|
||||||
var url =
|
var url =
|
||||||
'https://github.com/docsifyjs/docsify/blob/master/docs' +
|
'https://github.com/docsifyjs/docsify/blob/master/docs/' +
|
||||||
vm.route.file;
|
vm.route.file;
|
||||||
var editHtml = '[📝 EDIT DOCUMENT](' + url + ')\n';
|
var editHtml = '[📝 EDIT DOCUMENT](' + url + ')\n';
|
||||||
|
|
||||||
|
|||||||
+28
-12
@@ -21,48 +21,64 @@
|
|||||||
<script>
|
<script>
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
alias: {
|
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',
|
'/.*/_navbar.md': '/_navbar.md',
|
||||||
'/zh-cn/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-zh/master/$1',
|
'/zh-cn/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-zh/master/$1',
|
||||||
'/de-de/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-de/master/$1',
|
'/de-de/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-de/master/$1',
|
||||||
'/ru/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-ru/master/$1',
|
'/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'
|
||||||
},
|
},
|
||||||
notFoundPage: '_404.html',
|
|
||||||
auto2top: true,
|
auto2top: true,
|
||||||
basePath: '/docs/',
|
basePath: '/docs/',
|
||||||
executeScript: true,
|
|
||||||
loadNavbar: true,
|
|
||||||
loadSidebar: true,
|
|
||||||
coverpage: true,
|
coverpage: true,
|
||||||
name: 'docsify',
|
executeScript: true,
|
||||||
subMaxLevel: 2,
|
loadSidebar: true,
|
||||||
|
loadNavbar: true,
|
||||||
mergeNavbar: 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}',
|
formatUpdated: '{MM}/{DD} {HH}:{mm}',
|
||||||
plugins: [
|
plugins: [
|
||||||
function (hook, vm) {
|
function (hook, vm) {
|
||||||
hook.beforeEach(function (html) {
|
hook.beforeEach(function (html) {
|
||||||
var url
|
|
||||||
if (/githubusercontent\.com/.test(vm.route.file)) {
|
if (/githubusercontent\.com/.test(vm.route.file)) {
|
||||||
url = vm.route.file
|
url = vm.route.file
|
||||||
.replace('raw.githubusercontent.com', 'github.com')
|
.replace('raw.githubusercontent.com', 'github.com')
|
||||||
.replace(/\/master/, '/blob/master')
|
.replace(/\/master/, '/blob/master')
|
||||||
} else {
|
} 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'
|
var editHtml = '[:memo: Edit Document](' + url + ')\n'
|
||||||
|
|
||||||
return editHtml
|
return editHtml
|
||||||
+ html
|
+ html
|
||||||
+ '\n\n----\n\n'
|
+ '\n\n----\n\n'
|
||||||
+ 'Last modified {docsify-updated} '
|
+ '<a href="https://docsify.js.org" target="_blank" style="color: inherit; font-weight: normal; text-decoration: none;">Powered by docsify</a>'
|
||||||
+ editHtml
|
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script src="/lib/docsify.js"></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>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+2
-1
@@ -25,7 +25,8 @@ export default function () {
|
|||||||
formatUpdated: '',
|
formatUpdated: '',
|
||||||
externalLinkTarget: '_blank',
|
externalLinkTarget: '_blank',
|
||||||
routerMode: 'hash',
|
routerMode: 'hash',
|
||||||
noCompileLinks: []
|
noCompileLinks: [],
|
||||||
|
relativePath: false
|
||||||
},
|
},
|
||||||
window.$docsify
|
window.$docsify
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ import {
|
|||||||
isAbsolutePath,
|
isAbsolutePath,
|
||||||
stringifyQuery,
|
stringifyQuery,
|
||||||
cleanPath,
|
cleanPath,
|
||||||
replaceSlug
|
replaceSlug,
|
||||||
|
resolvePath
|
||||||
} from '../util'
|
} from '../util'
|
||||||
import {noop, merge} from '../../util/core'
|
import {noop, merge} from '../../util/core'
|
||||||
|
|
||||||
@@ -73,9 +74,13 @@ export class History {
|
|||||||
if (local) {
|
if (local) {
|
||||||
const idIndex = currentRoute.indexOf('?')
|
const idIndex = currentRoute.indexOf('?')
|
||||||
path =
|
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)
|
return cleanPath('/' + path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,20 @@ export const cleanPath = cached(path => {
|
|||||||
return path.replace(/^\/+/, '/').replace(/([^:])\/{2,}/g, '$1/')
|
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) {
|
export function getPath(...args) {
|
||||||
return cleanPath(args.join('/'))
|
return cleanPath(args.join('/'))
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-4
@@ -7,10 +7,16 @@ function install(hook) {
|
|||||||
const main = dom.getNode('#main')
|
const main = dom.getNode('#main')
|
||||||
div.style = `width: ${main.clientWidth}px; margin: 0 auto 20px;`
|
div.style = `width: ${main.clientWidth}px; margin: 0 auto 20px;`
|
||||||
dom.appendTo(dom.find('.content'), div)
|
dom.appendTo(dom.find('.content'), div)
|
||||||
const script = dom.create('script')
|
})
|
||||||
const content = `gitalk.render('gitalk-container')`
|
|
||||||
script.textContent = content
|
hook.doneEach(_ => {
|
||||||
dom.appendTo(dom.body, script)
|
const el = document.getElementById('gitalk-container')
|
||||||
|
while (el.hasChildNodes()) {
|
||||||
|
el.removeChild(el.firstChild)
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
|
gitalk.render('gitalk-container')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -323,6 +323,9 @@ body.sticky
|
|||||||
|
|
||||||
.markdown-section iframe
|
.markdown-section iframe
|
||||||
border 1px solid #eee
|
border 1px solid #eee
|
||||||
|
/* fix horizontal overflow on iOS Safari */
|
||||||
|
width 1px
|
||||||
|
min-width 100%
|
||||||
|
|
||||||
.markdown-section table
|
.markdown-section table
|
||||||
border-collapse collapse
|
border-collapse collapse
|
||||||
|
|||||||
@@ -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