Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vuejs/vitepress
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.0-alpha.40
Choose a base ref
...
head repository: vuejs/vitepress
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.0.0-alpha.41
Choose a head ref
  • 15 commits
  • 43 files changed
  • 4 contributors

Commits on Jan 20, 2023

  1. chore: bump deps (#1820)

    brc-dd authored Jan 20, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9986f6c View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    fe52fa3 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    05430e4 View commit details

Commits on Jan 21, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    977dad0 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5d2fc3f View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1553dbc View commit details
  4. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0f145cb View commit details
  5. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8782c82 View commit details

Commits on Jan 24, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c35a1f0 View commit details

Commits on Jan 26, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3db532e View commit details

Commits on Jan 27, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    99858d7 View commit details
  2. feat(build): support rewrites (#1798)

    Co-authored-by: Kia Ishii <kia.king.08@gmail.com>
    brc-dd and kiaking authored Jan 27, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    00abac6 View commit details

Commits on Jan 28, 2023

  1. feat: stable cleanUrls (#1852)

    brc-dd authored Jan 28, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5ae4fbd View commit details
  2. chore: bump deps (#1853)

    brc-dd authored Jan 28, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    08e07d6 View commit details
  3. release: v1.0.0-alpha.41

    brc-dd committed Jan 28, 2023
    Copy the full SHA
    2a9ee9d View commit details
Showing with 1,673 additions and 771 deletions.
  1. +22 −0 .github/workflows/lock-threads.yml
  2. +0 −1 .npmrc
  3. +21 −0 CHANGELOG.md
  4. +6 −2 __tests__/e2e/multi-sidebar/index.test.ts
  5. +117 −82 __tests__/unit/client/theme-default/support/sidebar.test.ts
  6. +2 −1 docs/.vitepress/config.ts
  7. +21 −15 docs/config/app-configs.md
  8. +30 −11 docs/config/theme-configs.md
  9. +5 −5 docs/guide/getting-started.md
  10. +173 −0 docs/guide/routing.md
  11. +39 −14 docs/guide/theme-sidebar.md
  12. +19 −18 package.json
  13. +705 −302 pnpm-lock.yaml
  14. +14 −2 src/client/app/router.ts
  15. +1 −1 src/client/theme-default/components/VPAlgoliaSearchBox.vue
  16. +1 −1 src/client/theme-default/components/VPDocAsideOutline.vue
  17. +3 −1 src/client/theme-default/components/VPLink.vue
  18. +1 −5 src/client/theme-default/components/VPNavBar.vue
  19. +4 −14 src/client/theme-default/components/VPSidebar.vue
  20. +0 −128 src/client/theme-default/components/VPSidebarGroup.vue
  21. +213 −0 src/client/theme-default/components/VPSidebarItem.vue
  22. +0 −88 src/client/theme-default/components/VPSidebarLink.vue
  23. +2 −1 src/client/theme-default/composables/flyout.ts
  24. +1 −1 src/client/theme-default/composables/langs.ts
  25. +16 −2 src/client/theme-default/composables/outline.ts
  26. +83 −3 src/client/theme-default/composables/sidebar.ts
  27. +63 −10 src/client/theme-default/support/sidebar.ts
  28. +1 −1 src/client/theme-default/support/utils.ts
  29. +1 −1 src/client/tsconfig.json
  30. +3 −1 src/node/build/build.ts
  31. +2 −1 src/node/build/bundle.ts
  32. +2 −8 src/node/build/render.ts
  33. +46 −14 src/node/config.ts
  34. +2 −2 src/node/markdown/env.ts
  35. +1 −1 src/node/markdown/plugins/highlight.ts
  36. +2 −5 src/node/markdown/plugins/link.ts
  37. +11 −9 src/node/markdownToVue.ts
  38. +13 −2 src/node/plugin.ts
  39. +1 −2 src/shared/shared.ts
  40. +1 −1 src/shared/tsconfig.json
  41. +1 −1 tsconfig.json
  42. +23 −8 types/default-theme.d.ts
  43. +1 −6 types/shared.d.ts
22 changes: 22 additions & 0 deletions .github/workflows/lock-threads.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Lock Threads

on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:

permissions:
issues: write
pull-requests: write

concurrency:
group: lock

jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v4
with:
issue-inactive-days: 7
pr-inactive-days: 7
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
shell-emulator=true
update-notifier=false
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# [1.0.0-alpha.41](https://github.com/vuejs/vitepress/compare/v1.0.0-alpha.40...v1.0.0-alpha.41) (2023-01-28)


### Bug Fixes

* check document instead of window to detect browser ([#1833](https://github.com/vuejs/vitepress/issues/1833)) ([0f145cb](https://github.com/vuejs/vitepress/commit/0f145cb3c6568760199a9c8eee785aecaf0e0494))
* **router:** avoid duplicate history entries ([#1827](https://github.com/vuejs/vitepress/issues/1827)) ([1553dbc](https://github.com/vuejs/vitepress/commit/1553dbce8eac9ed4a65312d4590d6b0f9261135c))
* **theme:** don't show border on navbar when sidebar is there ([#1845](https://github.com/vuejs/vitepress/issues/1845)) ([3db532e](https://github.com/vuejs/vitepress/commit/3db532ed0999c9bddfd6bc90f6b627ae1b9178af))


### Features

* **build:** allow ignoring only localhost dead links ([#1821](https://github.com/vuejs/vitepress/issues/1821)) ([fe52fa3](https://github.com/vuejs/vitepress/commit/fe52fa34201dcfa87ac4886fe285331f0ef89ba8))
* **build:** expose vitepress site config to vite plugins ([#1822](https://github.com/vuejs/vitepress/issues/1822)) ([05430e4](https://github.com/vuejs/vitepress/commit/05430e45c90562b62796caba28c633070934d85f))
* **build:** support rewrites ([#1798](https://github.com/vuejs/vitepress/issues/1798)) ([00abac6](https://github.com/vuejs/vitepress/commit/00abac611664e12710e5152d0259390b22c0e8ca))
* stable `cleanUrls` ([#1852](https://github.com/vuejs/vitepress/issues/1852)) ([5ae4fbd](https://github.com/vuejs/vitepress/commit/5ae4fbde3843236e180e63e2cd2b7021efa0fad4))
* **theme:** allow removing badge text from outline ([#1825](https://github.com/vuejs/vitepress/issues/1825)) ([5d2fc3f](https://github.com/vuejs/vitepress/commit/5d2fc3f9228c9b26dec26264d0951d0f43b3d90d))
* **theme:** enable multi level sidebar nesting ([#1360](https://github.com/vuejs/vitepress/issues/1360)) ([#1835](https://github.com/vuejs/vitepress/issues/1835)) ([c35a1f0](https://github.com/vuejs/vitepress/commit/c35a1f0faee3702c0494fb22043ce058e7a2954c)), closes [#1361](https://github.com/vuejs/vitepress/issues/1361) [#1680](https://github.com/vuejs/vitepress/issues/1680)



# [1.0.0-alpha.40](https://github.com/vuejs/vitepress/compare/v1.0.0-alpha.39...v1.0.0-alpha.40) (2023-01-20)


8 changes: 6 additions & 2 deletions __tests__/e2e/multi-sidebar/index.test.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,9 @@ describe('test multi sidebar sort root', () => {
})

test('using / sidebar', async () => {
const sidebarLocator = page.locator('.VPSidebarGroup .title-text')
const sidebarLocator = page.locator(
'.VPSidebarItem.level-0 > .item > .link > .text'
)

const sidebarContent = await sidebarLocator.allTextContents()
expect(sidebarContent).toEqual([
@@ -22,7 +24,9 @@ describe('test multi sidebar sort order', () => {
})

test('using /multi-sidebar/ sidebar', async () => {
const sidebarLocator = page.locator('.VPSidebarGroup .title-text')
const sidebarLocator = page.locator(
'.VPSidebarItem.level-0 > .item > .link > .text'
)

const sidebarContent = await sidebarLocator.allTextContents()
expect(sidebarContent).toEqual(['Multi Sidebar'])
199 changes: 117 additions & 82 deletions __tests__/unit/client/theme-default/support/sidebar.test.ts
Original file line number Diff line number Diff line change
@@ -1,96 +1,131 @@
import { getSidebar } from 'client/theme-default/support/sidebar'
import { getSidebar, hasActiveLink } from 'client/theme-default/support/sidebar'

describe('client/theme-default/support/sidebar', () => {
const root = [
{
text: 'A',
collapsible: true,
items: [
{
text: 'A',
link: ''
}
]
},
{
text: 'B',
items: [
{
text: 'B',
link: ''
}
]
}
]
const another = [
{
text: 'C',
items: [
describe('getSidebar', () => {
const root = [
{
text: 'A',
collapsible: true,
items: [{ text: 'A', link: '' }]
},
{
text: 'B',
items: [{ text: 'B', link: '' }]
}
]

const another = [
{
text: 'C',
items: [{ text: 'C', link: '' }]
}
]

describe('normal sidebar sort', () => {
const normalSidebar = {
'/': root,
'/multi-sidebar/': another
}

test('gets `/` sidebar', () => {
expect(getSidebar(normalSidebar, '/')).toBe(root)
})

test('gets `/multi-sidebar/` sidebar', () => {
expect(getSidebar(normalSidebar, '/multi-sidebar/')).toBe(another)
})

test('gets `/` sidebar again', () => {
expect(getSidebar(normalSidebar, '/some-entry.html')).toBe(root)
})
})

describe('reversed sidebar sort', () => {
const reversedSidebar = {
'/multi-sidebar/': another,
'/': root
}

test('gets `/` sidebar', () => {
expect(getSidebar(reversedSidebar, '/')).toBe(root)
})

test('gets `/multi-sidebar/` sidebar', () => {
expect(getSidebar(reversedSidebar, '/multi-sidebar/')).toBe(another)
})

test('gets `/` sidebar again', () => {
expect(getSidebar(reversedSidebar, '/some-entry.html')).toBe(root)
})
})

describe('nested sidebar sort', () => {
const nested = [
{
text: 'C',
link: ''
text: 'D',
items: [{ text: 'D', link: '' }]
}
]
}
]
describe('normal sidebar sort', () => {
const normalSidebar = {
'/': root,
'/multi-sidebar/': another
}
test('gets / sidebar', () => {
expect(getSidebar(normalSidebar, '/')).toBe(root)
})
test('gets /multi-sidebar/ sidebar', () => {
expect(getSidebar(normalSidebar, '/multi-sidebar/')).toBe(another)
})
test('gets / sidebar again', () => {
expect(getSidebar(normalSidebar, '/some-entry.html')).toBe(root)
})
})
describe('reversed sidebar sort', () => {
const reversedSidebar = {
'/multi-sidebar/': another,
'/': root
}
test('gets / sidebar', () => {
expect(getSidebar(reversedSidebar, '/')).toBe(root)
})
test('gets /multi-sidebar/ sidebar', () => {
expect(getSidebar(reversedSidebar, '/multi-sidebar/')).toBe(another)
})
test('gets / sidebar again', () => {
expect(getSidebar(reversedSidebar, '/some-entry.html')).toBe(root)

const nestedSidebar = {
'/': root,
'/multi-sidebar/': another,
'/multi-sidebar/nested/': nested
}

test('gets `/` sidebar', () => {
expect(getSidebar(nestedSidebar, '/')).toBe(root)
})

test('gets `/multi-sidebar/` sidebar', () => {
expect(getSidebar(nestedSidebar, '/multi-sidebar/')).toBe(another)
})

test('gets `/multi-sidebar/nested/` sidebar', () => {
expect(getSidebar(nestedSidebar, '/multi-sidebar/nested/')).toBe(nested)
})

test('gets `/` sidebar again', () => {
expect(getSidebar(nestedSidebar, '/some-entry.html')).toBe(root)
})
})
})
describe('nested sidebar sort', () => {
const nested = [
{
text: 'D',

describe('hasActiveLink', () => {
test('checks `SidebarItem`', () => {
const item = {
text: 'Item 001',
items: [
{
text: 'D',
link: ''
}
{ text: 'Item 001', link: '/active-1' },
{ text: 'Item 002', link: '/active-2' }
]
}
]
const nestedSidebar = {
'/': root,
'/multi-sidebar/': another,
'/multi-sidebar/nested/': nested
}
test('gets / sidebar', () => {
expect(getSidebar(nestedSidebar, '/')).toBe(root)
})
test('gets /multi-sidebar/ sidebar', () => {
expect(getSidebar(nestedSidebar, '/multi-sidebar/')).toBe(another)
})
test('gets /multi-sidebar/nested/ sidebar', () => {
expect(getSidebar(nestedSidebar, '/multi-sidebar/nested/')).toBe(nested)

expect(hasActiveLink('active-1', item)).toBe(true)
expect(hasActiveLink('inactive', item)).toBe(false)
})
test('gets / sidebar again', () => {
expect(getSidebar(nestedSidebar, '/some-entry.html')).toBe(root)

test('checks `SidebarItem[]`', () => {
const item = [
{
text: 'Item 001',
items: [
{ text: 'Item 001', link: '/active-1' },
{ text: 'Item 002', link: '/active-2' }
]
},
{
text: 'Item 002',
items: [
{ text: 'Item 003', link: '/active-3' },
{ text: 'Item 004', link: '/active-4' }
]
}
]

expect(hasActiveLink('active-1', item)).toBe(true)
expect(hasActiveLink('active-3', item)).toBe(true)
expect(hasActiveLink('inactive', item)).toBe(false)
})
})
})
3 changes: 2 additions & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ export default defineConfig({
description: 'Vite & Vue powered static site generator.',

lastUpdated: true,
cleanUrls: 'without-subfolders',
cleanUrls: true,

head: [['meta', { name: 'theme-color', content: '#3c8772' }]],

@@ -84,6 +84,7 @@ function sidebarGuide() {
{ text: 'What is VitePress?', link: '/guide/what-is-vitepress' },
{ text: 'Getting Started', link: '/guide/getting-started' },
{ text: 'Configuration', link: '/guide/configuration' },
{ text: 'Routing', link: '/guide/routing' },
{ text: 'Deploying', link: '/guide/deploying' },
{ text: 'Internationalization', link: '/guide/i18n' }
]
36 changes: 21 additions & 15 deletions docs/config/app-configs.md
Original file line number Diff line number Diff line change
@@ -86,10 +86,10 @@ type HeadConfig =
## ignoreDeadLinks
- Type: `boolean`
- Type: `boolean | 'localhostLinks'`
- Default: `false`
When set to `true`, VitePress will not fail builds due to dead links.
When set to `true`, VitePress will not fail builds due to dead links. When set to `localhostLinks`, the build will fail on dead links, but won't check `localhost` links.
```ts
export default {
@@ -132,7 +132,7 @@ Configure Markdown parser options. VitePress uses [Markdown-it](https://github.c
```js
export default {
markdown: {
theme: 'material-palenight',
theme: 'material-theme-palenight',
lineNumbers: true
}
}
@@ -266,28 +266,34 @@ export default {
}
```

## cleanUrls (Experimental)
## cleanUrls

- Type: `'disabled' | 'without-subfolders' | 'with-subfolders'`
- Default: `'disabled'`
- Type: `boolean`
- Default: `false`

Allows removing trailing `.html` from URLs and, optionally, generating clean directory structure. Available modes:
Allows removing trailing `.html` from URLs.

| Mode | Page | Generated Page | URL |
| :--------------------: | :-------: | :---------------: | :---------: |
| `'disabled'` | `/foo.md` | `/foo.html` | `/foo.html` |
| `'without-subfolders'` | `/foo.md` | `/foo.html` | `/foo` |
| `'with-subfolders'` | `/foo.md` | `/foo/index.html` | `/foo` |
```ts
export default {
cleanUrls: true
}
```

::: warning
Enabling this may require additional configuration on your hosting platform. For it to work, your server must serve `/foo.html` on requesting `/foo` **without a redirect**.
:::

Enabling this may require additional configuration on your hosting platform. For it to work, your server must serve the generated page on requesting the URL (see above table) **without a redirect**.
## rewrites

:::
- Type: `Record<string, string>`

Defines custom directory <-> URL mappings. See [Routing: Customize the Mappings](/guide/routing#customize-the-mappings) for more details.

```ts
export default {
cleanUrls: 'with-subfolders'
rewrites: {
'source/:page': 'destination/:page'
}
}
```

Loading