-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Showing
18 changed files
with
577 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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
/docs | ||
/examples | ||
*.md | ||
*.vue | ||
dist | ||
|
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,22 @@ | ||
import { defineConfig } from '../../../src/node' | ||
|
||
export default defineConfig({ | ||
title: 'Configured Example', | ||
description: 'Example of configured options of VitePress', | ||
themeConfig: { | ||
sidebar: { | ||
'/': [ | ||
{ | ||
text: 'Frontmatter', | ||
collapsible: true, | ||
items: [ | ||
{ | ||
text: 'Multiple levels outline', | ||
link: '/frontmatter/multiple-levels-outline' | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
}) |
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,32 @@ | ||
import { expect, test } from 'vitest' | ||
import { page, vitePressTestUrl, waitForLayout } from '~utils' | ||
|
||
describe('outline', () => { | ||
beforeAll(async () => { | ||
await page.goto( | ||
vitePressTestUrl + '/frontmatter/multiple-levels-outline.html' | ||
) | ||
await waitForLayout() | ||
}) | ||
|
||
test('set outline to deep', async () => { | ||
const outlineLinksLocator = await page.locator( | ||
'.VPDocAsideOutline .root .outline-link' | ||
) | ||
|
||
const outlineLinksContent = await outlineLinksLocator.allTextContents() | ||
expect(outlineLinksContent).toEqual([ | ||
'h2 - 1', | ||
'h3 - 1', | ||
'h3 - 2', | ||
'h2 - 2', | ||
'h3 - 3' | ||
]) | ||
|
||
const linkHrefs = await outlineLinksLocator.evaluateAll((element) => | ||
element.map((element) => element.getAttribute('href')) | ||
) | ||
|
||
expect(linkHrefs).toEqual(['#h2-1', '#h3-1', '#h3-2', '#h2-2', '#h3-3']) | ||
}) | ||
}) |
41 changes: 41 additions & 0 deletions
41
examples/configured/frontmatter/multiple-levels-outline.md
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,41 @@ | ||
--- | ||
title: Multiple levels outline | ||
editLink: true | ||
outline: 'deep' | ||
--- | ||
|
||
# h1 - 1 | ||
|
||
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. | ||
|
||
## h2 - 1 | ||
|
||
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. | ||
|
||
### h3 - 1 | ||
|
||
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. | ||
|
||
#### h4 - 1 | ||
|
||
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. | ||
|
||
### h3 - 2 | ||
|
||
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. | ||
|
||
#### h4 - 2 | ||
|
||
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. | ||
|
||
## h2 - 2 | ||
|
||
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. | ||
|
||
### h3 - 3 | ||
|
||
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. | ||
|
||
#### h4 - 3 | ||
|
||
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. |
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,3 @@ | ||
# Full Configured VitePress Example | ||
|
||
WIP |
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,12 @@ | ||
{ | ||
"private": true, | ||
"name": "vitepress-example-configured", | ||
"scripts": { | ||
"dev": "vitepress dev", | ||
"build": "vitepress build", | ||
"serve": "vitepress serve" | ||
}, | ||
"devDependencies": { | ||
"vitepress": "workspace:*" | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
examples/minimal/__test__/__snapshots__/content.spec.ts.snap
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,13 @@ | ||
// Vitest Snapshot v1 | ||
|
||
exports[`render corrent content > main content 1`] = ` | ||
[ | ||
"Appearance", | ||
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", | ||
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.", | ||
"Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of \\"de Finibus Bonorum et Malorum\\" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, \\"Lorem ipsum dolor sit amet..\\", comes from a line in section 1.10.32.", | ||
"The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from \\"de Finibus Bonorum et Malorum\\" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.", | ||
"It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).", | ||
"There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.", | ||
] | ||
`; |
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 @@ | ||
import { beforeAll, expect, test } from 'vitest' | ||
import { page, waitForLayout } from '~utils' | ||
|
||
describe('render corrent content', () => { | ||
beforeAll(async () => { | ||
await waitForLayout() | ||
}) | ||
|
||
test('main content', async () => { | ||
const h1Locator = await page.locator('h1') | ||
const h2Locator = await page.locator('h2') | ||
const pLocator = await page.locator('.Layout p') | ||
|
||
const [h1Contents, h2Conetents, pContents] = await Promise.all([ | ||
h1Locator.allTextContents(), | ||
h2Locator.allTextContents(), | ||
pLocator.allTextContents() | ||
]) | ||
|
||
expect(h1Contents).toEqual(['Lorem Ipsum #']) | ||
expect(h2Conetents).toEqual([ | ||
'What is Lorem Ipsum? #', | ||
'Where does it come from? #', | ||
'Why do we use it? #', | ||
'Where can I get some? #' | ||
]) | ||
expect(pContents).toMatchSnapshot() | ||
}) | ||
|
||
test('outline', async () => { | ||
const outlineLinksLocator = await page.locator( | ||
'.VPDocAsideOutline .root .outline-link' | ||
) | ||
|
||
const outlineLinksCount = await outlineLinksLocator.count() | ||
expect(outlineLinksCount).toEqual(0) | ||
}) | ||
}) |
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,7 @@ | ||
{ | ||
"name": "vitepress-examples", | ||
"private": true, | ||
"devDependencies": { | ||
"vitepress": "workspace:*" | ||
} | ||
} |
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,7 @@ | ||
import { page } from './vitestSetup' | ||
|
||
export * from './vitestSetup' | ||
|
||
export async function waitForLayout() { | ||
await page.waitForSelector('#app .Layout') | ||
} |
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,21 @@ | ||
{ | ||
"include": ["."], | ||
"exclude": ["**/dist/**"], | ||
"compilerOptions": { | ||
"target": "ES2020", | ||
"module": "ESNext", | ||
"outDir": "dist", | ||
"baseUrl": ".", | ||
"allowJs": true, | ||
"esModuleInterop": true, | ||
"resolveJsonModule": true, | ||
"moduleResolution": "Node", | ||
"skipLibCheck": true, | ||
"noUnusedLocals": true, | ||
"jsx": "preserve", | ||
"types": ["vitepress/client", "vitest/globals", "node"], | ||
"paths": { | ||
"~utils": ["./test-utils.ts"] | ||
} | ||
} | ||
} |
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,49 @@ | ||
import os from 'os' | ||
import path from 'path' | ||
import fs from 'fs-extra' | ||
import type { BrowserServer } from 'playwright-chromium' | ||
import { chromium } from 'playwright-chromium' | ||
|
||
const DIR = path.join(os.tmpdir(), 'vitest_playwright_global_setup') | ||
|
||
let browserServer: BrowserServer | undefined | ||
|
||
export async function setup(): Promise<void> { | ||
browserServer = await chromium.launchServer({ | ||
headless: !process.env.VITE_DEBUG_SERVE, | ||
args: process.env.CI | ||
? ['--no-sandbox', '--disable-setuid-sandbox'] | ||
: undefined | ||
}) | ||
|
||
await fs.mkdirp(DIR) | ||
await fs.writeFile(path.join(DIR, 'wsEndpoint'), browserServer.wsEndpoint()) | ||
|
||
const tempDir = path.resolve(__dirname, '../examples-temp') | ||
await fs.ensureDir(tempDir) | ||
await fs.emptyDir(tempDir) | ||
await fs | ||
.copy(path.resolve(__dirname, '../examples'), tempDir, { | ||
dereference: false, | ||
filter(file) { | ||
file = file.replace(/\\/g, '/') | ||
return !file.includes('__tests__') && !file.match(/dist(\/|$)/) | ||
} | ||
}) | ||
.catch(async (error) => { | ||
if (error.code === 'EPERM' && error.syscall === 'symlink') { | ||
throw new Error( | ||
'Could not create symlinks. On Windows, consider activating Developer Mode to allow non-admin users to create symlinks by following the instructions at https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development.' | ||
) | ||
} else { | ||
throw error | ||
} | ||
}) | ||
} | ||
|
||
export async function teardown(): Promise<void> { | ||
browserServer?.close() | ||
if (!process.env.VITE_PRESERVE_BUILD_ARTIFACTS) { | ||
fs.removeSync(path.resolve(__dirname, '../examples-temp')) | ||
} | ||
} |
Oops, something went wrong.