Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs revamp #2032

Merged
merged 32 commits into from Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9ca6ba7
docs: update home page
yyx990803 Mar 2, 2023
1e47caf
docs: restructure
yyx990803 Mar 2, 2023
f16de5e
docs: rewrite getting started + init tips
yyx990803 Mar 2, 2023
c0d27a3
fix: respect command line minify and outDir options
yyx990803 Mar 3, 2023
791705b
fix: avoid deprecation warning when using --force
yyx990803 Mar 3, 2023
cf7111b
docs: cli reference
yyx990803 Mar 3, 2023
821f54c
fix: ensure HMR works properly for page outline
yyx990803 Mar 3, 2023
e8433a7
fix: extract all headers by default
yyx990803 Mar 4, 2023
7b06980
docs: adjust routing guide
yyx990803 Mar 4, 2023
f48bff3
docs: move default theme content to reference
yyx990803 Mar 4, 2023
716f7e4
feat: support $params in page components
yyx990803 Mar 6, 2023
4c81622
feat: expose params at top level in useData()
yyx990803 Mar 6, 2023
76b6160
docs: dynamic routes
yyx990803 Mar 6, 2023
efc26fd
docs: document globals
yyx990803 Mar 6, 2023
c066378
docs: revise writing section
yyx990803 Mar 6, 2023
2093c38
docs: restructure site config page
yyx990803 Mar 6, 2023
fc5d266
use consistent config for config template
yyx990803 Mar 6, 2023
6d22364
fix(theme): make tip box text color darker
yyx990803 Mar 7, 2023
929d77e
docs: more tweaks
yyx990803 Mar 7, 2023
514b927
docs: adjust intro
yyx990803 Mar 7, 2023
acc3b72
docs: mpa
yyx990803 Mar 7, 2023
00dae2b
feat: expose isNotFound on PageData, deperecate Theme.NotFound
yyx990803 Mar 7, 2023
ee778fd
feat: deprecate Theme.setup
yyx990803 Mar 7, 2023
d0ffb87
feat: support Theme.extends
yyx990803 Mar 7, 2023
f356157
docs: revise custom theme and default theme extending
yyx990803 Mar 7, 2023
2726466
feat(data-loader): pass watched files into load()
yyx990803 Mar 7, 2023
51178a2
feat(data-loader): defineLoader() type helper
yyx990803 Mar 7, 2023
740b745
docs: build time data loading
yyx990803 Mar 7, 2023
e646231
feat: export loadEnv from vite
yyx990803 Mar 7, 2023
3184d93
docs: cms, mpa, using vue edits
yyx990803 Mar 7, 2023
c0f22f4
docs: revise frontmatter docs
yyx990803 Mar 7, 2023
7f97b17
chore: update docs links in init template
yyx990803 Mar 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 1 addition & 6 deletions __tests__/e2e/dynamic-routes/[id].md
@@ -1,8 +1,3 @@
<script setup>
import { useData } from 'vitepress'
const { page } = useData()
</script>

<!-- @content -->

<pre class="params">{{ page.params }}</pre>
<pre class="params">{{ $params }}</pre>
15 changes: 6 additions & 9 deletions __tests__/e2e/static-data/static.data.ts
@@ -1,23 +1,20 @@
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'

const dirname = path.dirname(fileURLToPath(import.meta.url))
import { defineLoader } from 'vitepress'

type Data = Record<string, boolean>[]
export declare const data: Data

export default {
export default defineLoader({
watch: ['./data/*'],
async load(): Promise<Data> {
async load(files: string[]): Promise<Data> {
const foo = fs.readFileSync(
path.resolve(dirname, './data/foo.json'),
files.find((f) => f.endsWith('foo.json'))!,
'utf-8'
)
const bar = fs.readFileSync(
path.resolve(dirname, './data/bar.json'),
files.find((f) => f.endsWith('bar.json'))!,
'utf-8'
)
return [JSON.parse(foo), JSON.parse(bar)]
}
}
})
113 changes: 67 additions & 46 deletions __tests__/unit/client/theme-default/composables/outline.test.ts
Expand Up @@ -7,14 +7,23 @@ describe('client/theme-default/composables/outline', () => {
resolveHeaders(
[
{
level: 2,
title: 'h2 - 1',
link: '#h2-1'
},
{
level: 3,
title: 'h3 - 1',
link: '#h3-1'
level: 1,
title: 'h1 - 1',
link: '#h1-1',
children: [
{
level: 2,
title: 'h2 - 1',
link: '#h2-1',
children: [
{
level: 3,
title: 'h3 - 1',
link: '#h3-1'
}
]
}
]
}
],
[2, 3]
Expand Down Expand Up @@ -42,12 +51,14 @@ describe('client/theme-default/composables/outline', () => {
{
level: 2,
title: 'h2 - 1',
link: '#h2-1'
},
{
level: 3,
title: 'h3 - 1',
link: '#h3-1'
link: '#h2-1',
children: [
{
level: 3,
title: 'h3 - 1',
link: '#h3-1'
}
]
}
],
2
Expand All @@ -68,42 +79,52 @@ describe('client/theme-default/composables/outline', () => {
{
level: 2,
title: 'h2 - 1',
link: '#h2-1'
},
{
level: 3,
title: 'h3 - 1',
link: '#h3-1'
},
{
level: 4,
title: 'h4 - 1',
link: '#h4-1'
},
{
level: 3,
title: 'h3 - 2',
link: '#h3-2'
},
{
level: 4,
title: 'h4 - 2',
link: '#h4-2'
link: '#h2-1',
children: [
{
level: 3,
title: 'h3 - 1',
link: '#h3-1',
children: [
{
level: 4,
title: 'h4 - 1',
link: '#h4-1'
}
]
},
{
level: 3,
title: 'h3 - 2',
link: '#h3-2',
children: [
{
level: 4,
title: 'h4 - 2',
link: '#h4-2'
}
]
}
]
},
{
level: 2,
title: 'h2 - 2',
link: '#h2-2'
},
{
level: 3,
title: 'h3 - 3',
link: '#h3-3'
},
{
level: 4,
title: 'h4 - 3',
link: '#h4-3'
link: '#h2-2',
children: [
{
level: 3,
title: 'h3 - 3',
link: '#h3-3',
children: [
{
level: 4,
title: 'h4 - 3',
link: '#h4-3'
}
]
}
]
}
],
'deep'
Expand Down
134 changes: 94 additions & 40 deletions docs/.vitepress/config.ts
Expand Up @@ -14,19 +14,12 @@ export default defineConfig({

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

markdown: {
headers: {
level: [0, 0]
}
},

themeConfig: {
nav: nav(),

sidebar: {
'/guide/': sidebarGuide(),
'/config/': sidebarConfig(),
'/api/': sidebarGuide()
'/reference/': sidebarReference()
},

editLink: {
Expand Down Expand Up @@ -60,14 +53,9 @@ function nav() {
return [
{ text: 'Guide', link: '/guide/what-is-vitepress', activeMatch: '/guide/' },
{
text: 'Config Reference',
link: '/config/introduction',
activeMatch: '/config/'
},
{
text: 'Runtime API',
link: '/api/',
activeMatch: '/api/'
text: 'Reference',
link: '/reference/site-config',
activeMatch: '/reference/'
},
{
text: pkg.version,
Expand All @@ -93,9 +81,8 @@ function sidebarGuide() {
items: [
{ 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: 'Deploy', link: '/guide/deploy' }
]
},
{
Expand All @@ -113,45 +100,112 @@ function sidebarGuide() {
text: 'Customization',
collapsed: false,
items: [
// { text: 'Default Theme', link: '/guide/default-theme' },
// {
// text: 'Extending the Default Theme',
// link: '/guide/customization-extending-default-theme'
// },
{ text: 'Building a Custom Theme', link: '/guide/customization-intro' },
{ text: 'Using a Custom Theme', link: '/guide/custom-theme' },
{
text: 'Runtime API',
link: '/api/'
text: 'Extending the Default Theme',
link: '/guide/extending-default-theme'
},
{ text: 'Build-Time Data Loading', link: '/guide/data-loading' }
{ text: 'Build-Time Data Loading', link: '/guide/data-loading' },
{ text: 'Connecting to a CMS', link: '/guide/cms' }
]
},
{
text: 'Migrations',
text: 'Experimental',
collapsed: false,
items: [
{
text: 'Migration from VuePress',
link: '/guide/migration-from-vuepress'
},
{
text: 'Migration from VitePress 0.x',
link: '/guide/migration-from-vitepress-0'
text: 'MPA Mode',
link: '/guide/mpa-mode'
}
]
},
// {
// text: 'Migrations',
// collapsed: false,
// items: [
// {
// text: 'Migration from VuePress',
// link: '/guide/migration-from-vuepress'
// },
// {
// text: 'Migration from VitePress 0.x',
// link: '/guide/migration-from-vitepress-0'
// }
// ]
// },
{
text: 'Config & API Reference',
link: '/reference/site-config'
}
]
}

function sidebarConfig() {
function sidebarReference() {
return [
{
text: 'Config Reference',
text: 'Reference',
items: [
{ text: 'Introduction', link: '/config/introduction' },
{ text: 'App Config', link: '/config/app-config' },
{ text: 'Default Theme Config', link: '/config/theme-config' },
{ text: 'Frontmatter Config', link: '/config/frontmatter-config' }
{ text: 'Site Config', link: '/reference/site-config' },
{ text: 'Frontmatter Config', link: '/reference/frontmatter-config' },
{ text: 'Runtime API', link: '/reference/runtime-api' },
{ text: 'CLI', link: '/reference/cli' },
{
text: 'Default Theme',
items: [
{
text: 'Overview',
link: '/reference/default-theme-config'
},
{
text: 'Nav',
link: '/reference/default-theme-nav'
},
{
text: 'Sidebar',
link: '/reference/default-theme-sidebar'
},
{
text: 'Home Page',
link: '/reference/default-theme-home-page'
},
{
text: 'Footer',
link: '/reference/default-theme-footer'
},
{
text: 'Layout',
link: '/reference/default-theme-layout'
},
{
text: 'Badge',
link: '/reference/default-theme-badge'
},
{
text: 'Team Page',
link: '/reference/default-theme-team-page'
},
{
text: 'Prev / Next Links',
link: '/reference/default-theme-prev-next-links'
},
{
text: 'Edit Link',
link: '/reference/default-theme-edit-link'
},
{
text: 'Last Updated Timestamp',
link: '/reference/default-theme-last-updated'
},
{
text: 'Algolia Search',
link: '/reference/default-theme-search'
},
{
text: 'Carbon Ads',
link: '/reference/default-theme-carbon-ads'
}
]
}
]
}
]
Expand Down