Merge branch 'main' into docs/group-icons

pull/4437/head
Divyansh Singh 9 months ago committed by GitHub
commit d9b701afd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -2,6 +2,7 @@
[![test](https://github.com/vuejs/vitepress/workflows/Test/badge.svg)](https://github.com/vuejs/vitepress/actions) [![test](https://github.com/vuejs/vitepress/workflows/Test/badge.svg)](https://github.com/vuejs/vitepress/actions)
[![npm](https://img.shields.io/npm/v/vitepress)](https://www.npmjs.com/package/vitepress) [![npm](https://img.shields.io/npm/v/vitepress)](https://www.npmjs.com/package/vitepress)
[![nightly releases](https://img.shields.io/badge/nightly-releases-orange)](https://nightly.akryum.dev/vuejs/vitepress)
[![chat](https://img.shields.io/badge/chat-discord-blue?logo=discord)](https://chat.vuejs.org) [![chat](https://img.shields.io/badge/chat-discord-blue?logo=discord)](https://chat.vuejs.org)
--- ---

@ -22,7 +22,7 @@ Both internal and external links get special treatment.
### Internal Links ### Internal Links
Internal links are converted to router link for SPA navigation. Also, every `index.md` contained in each sub-directory will automatically be converted to `index.html`, with corresponding URL `/`. Internal links are converted to router links for SPA navigation. Also, every `index.md` contained in each sub-directory will automatically be converted to `index.html`, with corresponding URL `/`.
For example, given the following directory structure: For example, given the following directory structure:

@ -114,7 +114,7 @@ interface Router {
/** /**
* Called after the route changes. * Called after the route changes.
*/ */
onAfterRouteChanged?: (to: string) => Awaitable<void> onAfterRouteChange?: (to: string) => Awaitable<void>
} }
``` ```

@ -106,7 +106,7 @@ interface Router {
/** /**
* Llamado después del cambio de ruta. * Llamado después del cambio de ruta.
*/ */
onAfterRouteChanged?: (to: string) => Awaitable<void> onAfterRouteChange?: (to: string) => Awaitable<void>
} }
``` ```

@ -109,7 +109,7 @@ interface Router {
/** /**
* پس از تغییر مسیر فراخوانی می‌شود. * پس از تغییر مسیر فراخوانی می‌شود.
*/ */
onAfterRouteChanged?: (to: string) => Awaitable<void> onAfterRouteChange?: (to: string) => Awaitable<void>
} }
``` ```

@ -110,7 +110,7 @@ interface Router {
/** /**
* 라우트가 변경된 후 호출. * 라우트가 변경된 후 호출.
*/ */
onAfterRouteChanged?: (to: string) => Awaitable<void> onAfterRouteChange?: (to: string) => Awaitable<void>
} }
``` ```

@ -13,7 +13,7 @@
"@lunariajs/core": "^0.1.1", "@lunariajs/core": "^0.1.1",
"markdown-it-mathjax3": "^4.3.2", "markdown-it-mathjax3": "^4.3.2",
"open-cli": "^8.0.0", "open-cli": "^8.0.0",
"postcss-rtlcss": "^5.5.1", "postcss-rtlcss": "^5.6.0",
"vitepress": "workspace:*", "vitepress": "workspace:*",
"vitepress-plugin-group-icons": "^1.3.2" "vitepress-plugin-group-icons": "^1.3.2"
} }

@ -182,7 +182,7 @@ Você pode definir um título personalizado adicionando o texto imediatamente ap
**Entrada** **Entrada**
```md ````md
::: danger STOP ::: danger STOP
Zona de perigo, não prossiga Zona de perigo, não prossiga
::: :::
@ -192,7 +192,7 @@ Zona de perigo, não prossiga
console.log('Olá, VitePress!') console.log('Olá, VitePress!')
``` ```
::: :::
``` ````
**Saída** **Saída**

@ -106,7 +106,7 @@ interface Router {
/** /**
* Chamado após a mudança de rota. * Chamado após a mudança de rota.
*/ */
onAfterRouteChanged?: (to: string) => Awaitable<void> onAfterRouteChange?: (to: string) => Awaitable<void>
} }
``` ```

@ -106,7 +106,7 @@ interface Router {
/** /**
* Вызывается после изменения маршрута. * Вызывается после изменения маршрута.
*/ */
onAfterRouteChanged?: (to: string) => Awaitable<void> onAfterRouteChange?: (to: string) => Awaitable<void>
} }
``` ```

@ -109,7 +109,7 @@ interface Router {
/** /**
* 在路由更改后调用 * 在路由更改后调用
*/ */
onAfterRouteChanged?: (to: string) => Awaitable<void> onAfterRouteChange?: (to: string) => Awaitable<void>
} }
``` ```

@ -98,28 +98,28 @@
"*": "prettier --write --ignore-unknown" "*": "prettier --write --ignore-unknown"
}, },
"dependencies": { "dependencies": {
"@docsearch/css": "^3.7.0", "@docsearch/css": "^3.8.2",
"@docsearch/js": "^3.7.0", "@docsearch/js": "^3.8.2",
"@iconify-json/simple-icons": "^1.2.11", "@iconify-json/simple-icons": "^1.2.17",
"@shikijs/core": "^1.22.2", "@shikijs/core": "^1.24.4",
"@shikijs/transformers": "^1.22.2", "@shikijs/transformers": "^1.24.4",
"@shikijs/types": "^1.22.2", "@shikijs/types": "^1.24.4",
"@types/markdown-it": "^14.1.2", "@types/markdown-it": "^14.1.2",
"@vitejs/plugin-vue": "^5.1.4", "@vitejs/plugin-vue": "^5.2.1",
"@vue/devtools-api": "^7.6.3", "@vue/devtools-api": "^7.6.8",
"@vue/shared": "^3.5.12", "@vue/shared": "^3.5.13",
"@vueuse/core": "^11.2.0", "@vueuse/core": "^12.2.0",
"@vueuse/integrations": "^11.2.0", "@vueuse/integrations": "^12.2.0",
"focus-trap": "^7.6.0", "focus-trap": "^7.6.2",
"mark.js": "8.11.1", "mark.js": "8.11.1",
"minisearch": "^7.1.0", "minisearch": "^7.1.1",
"shiki": "^1.22.2", "shiki": "^1.24.4",
"vite": "^5.4.10", "vite": "^5.4.11",
"vue": "^3.5.12" "vue": "^3.5.13"
}, },
"devDependencies": { "devDependencies": {
"@clack/prompts": "^0.7.0", "@clack/prompts": "^0.9.0",
"@iconify/utils": "^2.1.33", "@iconify/utils": "^2.2.1",
"@mdit-vue/plugin-component": "^2.1.3", "@mdit-vue/plugin-component": "^2.1.3",
"@mdit-vue/plugin-frontmatter": "^2.1.3", "@mdit-vue/plugin-frontmatter": "^2.1.3",
"@mdit-vue/plugin-headers": "^2.1.3", "@mdit-vue/plugin-headers": "^2.1.3",
@ -129,10 +129,10 @@
"@mdit-vue/shared": "^2.1.3", "@mdit-vue/shared": "^2.1.3",
"@polka/compression": "^1.0.0-next.28", "@polka/compression": "^1.0.0-next.28",
"@rollup/plugin-alias": "^5.1.1", "@rollup/plugin-alias": "^5.1.1",
"@rollup/plugin-commonjs": "^28.0.1", "@rollup/plugin-commonjs": "^28.0.2",
"@rollup/plugin-json": "^6.1.0", "@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.3.0", "@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-replace": "^6.0.1", "@rollup/plugin-replace": "^6.0.2",
"@types/cross-spawn": "^6.0.6", "@types/cross-spawn": "^6.0.6",
"@types/debug": "^4.1.12", "@types/debug": "^4.1.12",
"@types/fs-extra": "^11.0.4", "@types/fs-extra": "^11.0.4",
@ -143,55 +143,54 @@
"@types/markdown-it-emoji": "^3.0.1", "@types/markdown-it-emoji": "^3.0.1",
"@types/micromatch": "^4.0.9", "@types/micromatch": "^4.0.9",
"@types/minimist": "^1.2.5", "@types/minimist": "^1.2.5",
"@types/node": "^22.9.0", "@types/node": "^22.10.2",
"@types/postcss-prefix-selector": "^1.16.3", "@types/postcss-prefix-selector": "^1.16.3",
"@types/prompts": "^2.4.9", "@types/prompts": "^2.4.9",
"chokidar": "^3.6.0", "chokidar": "^4.0.3",
"conventional-changelog-cli": "^5.0.0", "conventional-changelog-cli": "^5.0.0",
"cross-spawn": "^7.0.3", "cross-spawn": "^7.0.6",
"debug": "^4.3.7", "debug": "^4.4.0",
"esbuild": "^0.24.0", "esbuild": "^0.24.2",
"execa": "^9.5.1", "execa": "^9.5.2",
"fs-extra": "^11.2.0", "fs-extra": "^11.2.0",
"get-port": "^7.1.0", "get-port": "^7.1.0",
"gray-matter": "^4.0.3", "gray-matter": "^4.0.3",
"lint-staged": "^15.2.10", "lint-staged": "^15.3.0",
"lodash.template": "^4.5.0", "lodash.template": "^4.5.0",
"lru-cache": "^11.0.2", "lru-cache": "^11.0.2",
"markdown-it": "^14.1.0", "markdown-it": "^14.1.0",
"markdown-it-anchor": "^9.2.0", "markdown-it-anchor": "^9.2.0",
"markdown-it-attrs": "^4.2.0", "markdown-it-attrs": "^4.3.1",
"markdown-it-container": "^4.0.0", "markdown-it-container": "^4.0.0",
"markdown-it-emoji": "^3.0.0", "markdown-it-emoji": "^3.0.0",
"markdown-it-mathjax3": "^4.3.2", "markdown-it-mathjax3": "^4.3.2",
"micromatch": "^4.0.8", "micromatch": "^4.0.8",
"minimist": "^1.2.8", "minimist": "^1.2.8",
"nanoid": "^5.0.8", "nanoid": "^5.0.9",
"ora": "^8.1.1", "ora": "^8.1.1",
"p-map": "^7.0.2", "p-map": "^7.0.3",
"path-to-regexp": "^6.3.0", "path-to-regexp": "^6.3.0",
"picocolors": "^1.1.1", "picocolors": "^1.1.1",
"pkg-dir": "^8.0.0", "pkg-dir": "^8.0.0",
"playwright-chromium": "^1.48.2", "playwright-chromium": "^1.49.1",
"polka": "^1.0.0-next.28", "polka": "^1.0.0-next.28",
"postcss-prefix-selector": "^2.1.0", "postcss-prefix-selector": "^2.1.0",
"prettier": "^3.3.3", "prettier": "^3.4.2",
"prompts": "^2.4.2", "prompts": "^2.4.2",
"punycode": "^2.3.1", "punycode": "^2.3.1",
"rimraf": "^6.0.1", "rimraf": "^6.0.1",
"rollup": "^4.24.4", "rollup": "^4.29.1",
"rollup-plugin-dts": "^6.1.1", "rollup-plugin-dts": "^6.1.1",
"rollup-plugin-esbuild": "^6.1.1", "rollup-plugin-esbuild": "^6.1.1",
"semver": "^7.6.3", "semver": "^7.6.3",
"simple-git-hooks": "^2.11.1", "simple-git-hooks": "^2.11.1",
"sirv": "^3.0.0", "sirv": "^3.0.0",
"sitemap": "^8.0.0", "sitemap": "^8.0.0",
"supports-color": "^9.4.0",
"synckit": "^0.9.2", "synckit": "^0.9.2",
"tinyglobby": "^0.2.10", "tinyglobby": "^0.2.10",
"typescript": "^5.6.3", "typescript": "^5.7.2",
"vitest": "^2.1.4", "vitest": "^2.1.8",
"vue-tsc": "^2.1.10", "vue-tsc": "^2.2.0",
"wait-on": "^8.0.1" "wait-on": "^8.0.1"
}, },
"peerDependencies": { "peerDependencies": {
@ -206,7 +205,7 @@
"optional": true "optional": true
} }
}, },
"packageManager": "pnpm@9.12.3", "packageManager": "pnpm@9.15.2",
"pnpm": { "pnpm": {
"peerDependencyRules": { "peerDependencyRules": {
"ignoreMissing": [ "ignoreMissing": [

File diff suppressed because it is too large Load Diff

@ -1,5 +1,5 @@
import { copy, remove } from 'fs-extra'
import { watch } from 'chokidar' import { watch } from 'chokidar'
import { copy, remove } from 'fs-extra'
import { normalizePath } from 'vite' import { normalizePath } from 'vite'
function toClientAndNode(method, file) { function toClientAndNode(method, file) {
@ -18,14 +18,19 @@ function toDist(file) {
} }
// copy shared files to the client and node directory whenever they change. // copy shared files to the client and node directory whenever they change.
watch('src/shared/**/*.ts') watch('src/shared', {
ignored: (path, stats) => stats?.isFile() && !path.endsWith('.ts')
})
.on('change', (file) => toClientAndNode('copy', file)) .on('change', (file) => toClientAndNode('copy', file))
.on('add', (file) => toClientAndNode('copy', file)) .on('add', (file) => toClientAndNode('copy', file))
.on('unlink', (file) => toClientAndNode('remove', file)) .on('unlink', (file) => toClientAndNode('remove', file))
// copy non ts files, such as an html or css, to the dist directory whenever // copy non ts files, such as an html or css, to the dist directory whenever
// they change. // they change.
watch('src/client/**/!(*.ts|tsconfig.json)') watch('src/client', {
ignored: (path, stats) =>
stats?.isFile() && (path.endsWith('.ts') || path.endsWith('tsconfig.json'))
})
.on('change', (file) => copy(file, toDist(file))) .on('change', (file) => copy(file, toDist(file)))
.on('add', (file) => copy(file, toDist(file))) .on('add', (file) => copy(file, toDist(file)))
.on('unlink', (file) => remove(toDist(file))) .on('unlink', (file) => remove(toDist(file)))

@ -36,6 +36,10 @@ export interface Router {
/** /**
* Called after the route changes. * Called after the route changes.
*/ */
onAfterRouteChange?: (to: string) => Awaitable<void>
/**
* @deprecated use `onAfterRouteChange` instead
*/
onAfterRouteChanged?: (to: string) => Awaitable<void> onAfterRouteChanged?: (to: string) => Awaitable<void>
} }
@ -76,7 +80,7 @@ export function createRouter(
history.pushState({}, '', href) history.pushState({}, '', href)
} }
await loadPage(href) await loadPage(href)
await router.onAfterRouteChanged?.(href) await (router.onAfterRouteChange ?? router.onAfterRouteChanged)?.(href)
} }
let latestPendingPath: string | null = null let latestPendingPath: string | null = null
@ -245,14 +249,10 @@ export function createRouter(
) )
window.addEventListener('popstate', async (e) => { window.addEventListener('popstate', async (e) => {
if (e.state === null) { if (e.state === null) return
return const href = normalizeHref(location.href)
} await loadPage(href, (e.state && e.state.scrollPosition) || 0)
await loadPage( await (router.onAfterRouteChange ?? router.onAfterRouteChanged)?.(href)
normalizeHref(location.href),
(e.state && e.state.scrollPosition) || 0
)
router.onAfterRouteChanged?.(location.href)
}) })
window.addEventListener('hashchange', (e) => { window.addEventListener('hashchange', (e) => {

@ -46,9 +46,9 @@
font-weight: 100 900; font-weight: 100 900;
font-display: swap; font-display: swap;
src: url('../fonts/inter-roman-vietnamese.woff2') format('woff2'); src: url('../fonts/inter-roman-vietnamese.woff2') format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169,
U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323,
U+1EA0-1EF9, U+20AB; U+0329, U+1EA0-1EF9, U+20AB;
} }
@font-face { @font-face {
@ -116,9 +116,9 @@
font-weight: 100 900; font-weight: 100 900;
font-display: swap; font-display: swap;
src: url('../fonts/inter-italic-vietnamese.woff2') format('woff2'); src: url('../fonts/inter-italic-vietnamese.woff2') format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169,
U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323,
U+1EA0-1EF9, U+20AB; U+0329, U+1EA0-1EF9, U+20AB;
} }
@font-face { @font-face {

@ -10,7 +10,7 @@ import { rimraf } from 'rimraf'
import type { BuildOptions, Rollup } from 'vite' import type { BuildOptions, Rollup } from 'vite'
import { resolveConfig, type SiteConfig } from '../config' import { resolveConfig, type SiteConfig } from '../config'
import { clearCache } from '../markdownToVue' import { clearCache } from '../markdownToVue'
import { slash, type HeadConfig } from '../shared' import { slash, type Awaitable, type HeadConfig } from '../shared'
import { deserializeFunctions, serializeFunctions } from '../utils/fnSerialize' import { deserializeFunctions, serializeFunctions } from '../utils/fnSerialize'
import { task } from '../utils/task' import { task } from '../utils/task'
import { bundle } from './bundle' import { bundle } from './bundle'
@ -21,12 +21,20 @@ const require = createRequire(import.meta.url)
export async function build( export async function build(
root?: string, root?: string,
buildOptions: BuildOptions & { base?: string; mpa?: string } = {} buildOptions: BuildOptions & {
base?: string
mpa?: string
onAfterConfigResolve?: (siteConfig: SiteConfig) => Awaitable<void>
} = {}
) { ) {
const start = Date.now() const start = Date.now()
process.env.NODE_ENV = 'production' process.env.NODE_ENV = 'production'
const siteConfig = await resolveConfig(root, 'build', 'production') const siteConfig = await resolveConfig(root, 'build', 'production')
await buildOptions.onAfterConfigResolve?.(siteConfig)
delete buildOptions.onAfterConfigResolve
const unlinkVue = linkVue() const unlinkVue = linkVue()
if (buildOptions.base) { if (buildOptions.base) {
@ -138,8 +146,9 @@ export async function build(
iconSelector: '.vpi-social-{name}', iconSelector: '.vpi-social-{name}',
commonSelector: '.vpi-social', commonSelector: '.vpi-social',
varName: 'icon', varName: 'icon',
format: process.env.DEBUG ? 'expanded' : 'compressed' format: process.env.DEBUG ? 'expanded' : 'compressed',
}).replace(/.*?}/, '') mode: 'mask'
}).replace(/[^]*?}\n*/, '')
fs.writeFileSync(path.join(siteConfig.outDir, 'vp-icons.css'), iconsCss) fs.writeFileSync(path.join(siteConfig.outDir, 'vp-icons.css'), iconsCss)
}) })

@ -101,9 +101,9 @@ export async function bundle(
rollupOptions: { rollupOptions: {
...rollupOptions, ...rollupOptions,
input: { input: {
...input,
// use different entry based on ssr or not // use different entry based on ssr or not
app: path.resolve(APP_PATH, ssr ? 'ssr.js' : 'index.js') app: path.resolve(APP_PATH, ssr ? 'ssr.js' : 'index.js'),
...input
}, },
// important so that each page chunk and the index export things for each // important so that each page chunk and the index export things for each
// other // other

@ -1,6 +1,6 @@
import minimist from 'minimist' import minimist from 'minimist'
import c from 'picocolors' import c from 'picocolors'
import { createLogger } from 'vite' import { createLogger, type Logger } from 'vite'
import { build, createServer, serve } from '.' import { build, createServer, serve } from '.'
import { version } from '../../package.json' import { version } from '../../package.json'
import { init } from './init/init' import { init } from './init/init'
@ -12,7 +12,7 @@ if (process.env.DEBUG) {
const argv: any = minimist(process.argv.slice(2)) const argv: any = minimist(process.argv.slice(2))
const logVersion = (logger = createLogger()) => { const logVersion = (logger: Logger) => {
logger.info(`\n ${c.green(`${c.bold('vitepress')} v${version}`)}\n`, { logger.info(`\n ${c.green(`${c.bold('vitepress')} v${version}`)}\n`, {
clear: !logger.hasWarned clear: !logger.hasWarned
}) })
@ -60,9 +60,13 @@ if (!command || command === 'dev') {
createLogger().info('', { clear: true }) createLogger().info('', { clear: true })
init(argv.root) init(argv.root)
} else { } else {
logVersion()
if (command === 'build') { if (command === 'build') {
build(root, argv).catch((err) => { build(root, {
...argv,
onAfterConfigResolve(siteConfig) {
logVersion(siteConfig.logger)
}
}).catch((err) => {
createLogger().error( createLogger().error(
`${c.red(`build error:`)}\n${err.message}\n${err.stack}` `${c.red(`build error:`)}\n${err.message}\n${err.stack}`
) )

@ -46,6 +46,7 @@ export async function init(root: string | undefined) {
initialValue: './', initialValue: './',
validate(value) { validate(value) {
// TODO make sure directory is inside // TODO make sure directory is inside
return undefined
} }
}) })
}, },

Loading…
Cancel
Save