mirror of https://github.com/vuejs/vitepress
commit
277688a104
@ -0,0 +1,27 @@
|
||||
# header 1
|
||||
|
||||
header 1 content
|
||||
|
||||
## header 1.1
|
||||
|
||||
header 1.1 content
|
||||
|
||||
### header 1.1.1
|
||||
|
||||
header 1.1.1 content
|
||||
|
||||
### header 1.1.2
|
||||
|
||||
header 1.1.2 content
|
||||
|
||||
## header 1.2
|
||||
|
||||
header 1.2 content
|
||||
|
||||
### header 1.2.1
|
||||
|
||||
header 1.2.1 content
|
||||
|
||||
### header 1.2.2
|
||||
|
||||
header 1.2.2 content
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
@ -1,2 +1,16 @@
|
||||
#!/usr/bin/env node
|
||||
// @ts-check
|
||||
|
||||
import module from 'node:module'
|
||||
|
||||
// https://github.com/vitejs/vite/blob/6c8a5a27e645a182f5b03a4ed6aa726eab85993f/packages/vite/bin/vite.js#L48-L63
|
||||
try {
|
||||
module.enableCompileCache?.()
|
||||
setTimeout(() => {
|
||||
try {
|
||||
module.flushCompileCache?.()
|
||||
} catch {}
|
||||
}, 10 * 1000).unref()
|
||||
} catch {}
|
||||
|
||||
import('../dist/node/cli.js')
|
||||
|
@ -1,22 +0,0 @@
|
||||
import { defineConfig } from 'vitepress'
|
||||
import { shared } from './shared'
|
||||
import { en } from './en'
|
||||
import { zh } from './zh'
|
||||
import { pt } from './pt'
|
||||
import { ru } from './ru'
|
||||
import { es } from './es'
|
||||
import { ko } from './ko'
|
||||
import { fa } from './fa'
|
||||
|
||||
export default defineConfig({
|
||||
...shared,
|
||||
locales: {
|
||||
root: { label: 'English', ...en },
|
||||
zh: { label: '简体中文', ...zh },
|
||||
pt: { label: 'Português', ...pt },
|
||||
ru: { label: 'Русский', ...ru },
|
||||
es: { label: 'Español', ...es },
|
||||
ko: { label: '한국어', ...ko },
|
||||
fa: { label: 'فارسی', ...fa }
|
||||
}
|
||||
})
|
@ -1,10 +1,10 @@
|
||||
import { createRequire } from 'module'
|
||||
import { defineConfig, type DefaultTheme } from 'vitepress'
|
||||
import { defineAdditionalConfig, type DefaultTheme } from 'vitepress'
|
||||
|
||||
const require = createRequire(import.meta.url)
|
||||
const pkg = require('vitepress/package.json')
|
||||
|
||||
export const en = defineConfig({
|
||||
export default defineAdditionalConfig({
|
||||
lang: 'en-US',
|
||||
description: 'Vite & Vue powered static site generator.',
|
||||
|
@ -0,0 +1 @@
|
||||
../../art/vitepress-logo.svg
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 33 B |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 33 B |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,104 @@
|
||||
import { inBrowser, onContentUpdated, useRoute } from 'vitepress'
|
||||
import type { DefaultTheme, useLayout as expected } from 'vitepress/theme'
|
||||
import { computed, shallowReadonly, shallowRef, watch } from 'vue'
|
||||
import { getSidebar, getSidebarGroups } from '../support/sidebar'
|
||||
import { useData } from './data'
|
||||
import { getHeaders } from './outline'
|
||||
import { useCloseSidebarOnEscape } from './sidebar'
|
||||
|
||||
const headers = shallowRef<DefaultTheme.OutlineItem[]>([])
|
||||
const sidebar = shallowRef<DefaultTheme.SidebarItem[]>([])
|
||||
|
||||
const is960 = shallowRef(false)
|
||||
|
||||
export function useLayout(): ReturnType<typeof expected> {
|
||||
const { frontmatter, theme } = useData()
|
||||
|
||||
const isHome = computed(() => {
|
||||
return !!(frontmatter.value.isHome ?? frontmatter.value.layout === 'home')
|
||||
})
|
||||
|
||||
const hasSidebar = computed(() => {
|
||||
return (
|
||||
frontmatter.value.sidebar !== false &&
|
||||
sidebar.value.length > 0 &&
|
||||
!isHome.value
|
||||
)
|
||||
})
|
||||
|
||||
const isSidebarEnabled = computed(() => hasSidebar.value && is960.value)
|
||||
|
||||
const sidebarGroups = computed(() => {
|
||||
return hasSidebar.value ? getSidebarGroups(sidebar.value) : []
|
||||
})
|
||||
|
||||
const hasAside = computed(() => {
|
||||
if (isHome.value) return false
|
||||
if (frontmatter.value.aside != null) return !!frontmatter.value.aside
|
||||
return theme.value.aside !== false
|
||||
})
|
||||
|
||||
const leftAside = computed(() => {
|
||||
if (!hasAside.value) return false
|
||||
return frontmatter.value.aside == null
|
||||
? theme.value.aside === 'left'
|
||||
: frontmatter.value.aside === 'left'
|
||||
})
|
||||
|
||||
const hasLocalNav = computed(() => {
|
||||
return headers.value.length > 0
|
||||
})
|
||||
|
||||
return {
|
||||
isHome,
|
||||
sidebar: shallowReadonly(sidebar),
|
||||
sidebarGroups,
|
||||
hasSidebar,
|
||||
isSidebarEnabled,
|
||||
hasAside,
|
||||
leftAside,
|
||||
headers: shallowReadonly(headers),
|
||||
hasLocalNav
|
||||
}
|
||||
}
|
||||
|
||||
interface RegisterWatchersOptions {
|
||||
closeSidebar: () => void
|
||||
}
|
||||
|
||||
export function registerWatchers({ closeSidebar }: RegisterWatchersOptions) {
|
||||
const { frontmatter, page, theme } = useData()
|
||||
|
||||
watch(
|
||||
() => [page.value.relativePath, theme.value.sidebar] as const,
|
||||
([relativePath, sidebarConfig]) => {
|
||||
const newSidebar = sidebarConfig
|
||||
? getSidebar(sidebarConfig, relativePath)
|
||||
: []
|
||||
if (JSON.stringify(newSidebar) !== JSON.stringify(sidebar.value)) {
|
||||
sidebar.value = newSidebar
|
||||
}
|
||||
},
|
||||
{ immediate: true, deep: true, flush: 'sync' }
|
||||
)
|
||||
|
||||
onContentUpdated(() => {
|
||||
headers.value = getHeaders(frontmatter.value.outline ?? theme.value.outline)
|
||||
})
|
||||
|
||||
if (inBrowser) {
|
||||
is960.value = window.innerWidth >= 960
|
||||
window.addEventListener(
|
||||
'resize',
|
||||
() => {
|
||||
is960.value = window.innerWidth >= 960
|
||||
},
|
||||
{ passive: true }
|
||||
)
|
||||
}
|
||||
|
||||
const route = useRoute()
|
||||
watch(() => route.path, closeSidebar)
|
||||
|
||||
useCloseSidebarOnEscape(closeSidebar)
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue