-
Notifications
You must be signed in to change notification settings - Fork 920
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca7eb8c
commit 34bb3a1
Showing
6 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
meta: | ||
a: 0 | ||
c: 3 | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
## GetPagesPath | ||
|
||
<ul class="get-pages-path"> | ||
<li v-for="path in pagesPath"> | ||
{{path}} | ||
</li> | ||
</ul> | ||
|
||
## isPageExist | ||
|
||
<div class="is-page-exist"> | ||
|
||
- /: {{isPageExist('/')}} | ||
- /README.md: {{isPageExist('/README.md')}} | ||
- /index.html: {{isPageExist('/index.html')}} | ||
- /not-exist: {{isPageExist('/not-exist')}} | ||
- /not-exist.html: {{isPageExist('/not-exist.html')}} | ||
- /not-exist.md: {{isPageExist('/not-exist.md')}} | ||
- /zh/: {{isPageExist('/zh/')}} | ||
- /zh: {{isPageExist('/zh')}} | ||
|
||
</div> | ||
|
||
## resolve | ||
|
||
<div class="resolve"> | ||
|
||
- Clean url: {{JSON.stringify(resolve('/page-data/meta'))}} | ||
- HTML: {{JSON.stringify(resolve('/page-data/meta.html'))}} | ||
- Markdown: {{JSON.stringify(resolve('/page-data/meta.md'))}} | ||
|
||
</div> | ||
|
||
<script setup> | ||
import { getPagesPath, isPageExist, pagesMap, resolve } from '@vuepress/client' | ||
|
||
const pagesPath = getPagesPath(); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
context('router', () => { | ||
it('getPagesPath', () => { | ||
cy.visit('/router.html') | ||
|
||
const paths = [ | ||
'/', | ||
'/layouts/custom-layout.html', | ||
'/layouts/layout.html', | ||
'/markdown/code-blocks.html', | ||
'/markdown/emoji.html', | ||
'/markdown/import-code-blocks.html', | ||
'/markdown/toc.html', | ||
'/markdown/vue-components.html', | ||
'/markdown/links/bar.html', | ||
'/markdown/links/baz.html', | ||
'/markdown/links/foo.html', | ||
'/page-data/frontmatter.html', | ||
'/page-data/headers.html', | ||
'/page-data/lang.html', | ||
'/page-data/meta.html', | ||
'/page-data/permalink.html', | ||
'/page-data/title-from-frontmatter.html', | ||
'/page-data/title-from-h1.html', | ||
'/router.html', | ||
'/zh/', | ||
'/404.html', | ||
] | ||
|
||
cy.get('.e2e-theme-content ul.get-pages-path li').each((el) => { | ||
expect(paths.includes(el.text())).to.equal(true) | ||
}) | ||
}) | ||
|
||
it('isPageExist', () => { | ||
cy.visit('/router.html') | ||
const results = [ | ||
'/: true', | ||
'/README.md: true', | ||
'/index.html: true', | ||
'/not-exist: false', | ||
'/not-exist.html: false', | ||
'/not-exist.md: false', | ||
'/zh/: true', | ||
'/zh: false', | ||
] | ||
|
||
cy.get('.e2e-theme-content .is-page-exist ul li').each((el) => { | ||
expect(results.includes(el.text())).to.equal(true) | ||
}) | ||
}) | ||
|
||
it('resolve', () => { | ||
cy.visit('/router.html') | ||
const result = { path: '/page-data/meta.html', meta: { a: 0, b: 2, c: 3 } } | ||
|
||
cy.get('.e2e-theme-content .resolve ul li').each((el) => { | ||
expect(el.text()).to.contain(JSON.stringify(result)) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters