Merge branch 'vuejs:main' into main

pull/3361/head
wChenonly 2 years ago committed by GitHub
commit ba0395d47d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,3 +1,14 @@
# [1.0.0-rc.33](https://github.com/vuejs/vitepress/compare/v1.0.0-rc.32...v1.0.0-rc.33) (2023-12-26)
### Features
- allow explicitly mark code element as `.vp-copy-ignore` ([#3360](https://github.com/vuejs/vitepress/issues/3360)) ([93122ee](https://github.com/vuejs/vitepress/commit/93122eee20cb6586026c1ffac04d9787861cc2f3))
- **build:** enable VUE_PROD_HYDRATION_MISMATCH_DETAILS when DEBUG is truthy ([f4d4280](https://github.com/vuejs/vitepress/commit/f4d4280d7d1728a966bb04968a9bac10470c3d06)), closes [#422](https://github.com/vuejs/vitepress/issues/422)
### Performance Improvements
- implement concurrent promise pooling for render task ([#3366](https://github.com/vuejs/vitepress/issues/3366))
# [1.0.0-rc.32](https://github.com/vuejs/vitepress/compare/v1.0.0-rc.31...v1.0.0-rc.32) (2023-12-16) # [1.0.0-rc.32](https://github.com/vuejs/vitepress/compare/v1.0.0-rc.31...v1.0.0-rc.32) (2023-12-16)
### Features ### Features

@ -212,6 +212,9 @@ interface TeamMember {
// URL for the sponsor page for the member. // URL for the sponsor page for the member.
sponsor?: string sponsor?: string
// Text for the sponsor link. Defaults to 'Sponsor'.
actionText?: string
} }
``` ```

@ -1,6 +1,6 @@
{ {
"name": "vitepress", "name": "vitepress",
"version": "1.0.0-rc.32", "version": "1.0.0-rc.33",
"description": "Vite & Vue powered static site generator", "description": "Vite & Vue powered static site generator",
"type": "module", "type": "module",
"packageManager": "pnpm@8.12.1", "packageManager": "pnpm@8.12.1",
@ -93,18 +93,18 @@
"@docsearch/css": "^3.5.2", "@docsearch/css": "^3.5.2",
"@docsearch/js": "^3.5.2", "@docsearch/js": "^3.5.2",
"@types/markdown-it": "^13.0.7", "@types/markdown-it": "^13.0.7",
"@vitejs/plugin-vue": "^4.5.2", "@vitejs/plugin-vue": "^5.0.0",
"@vue/devtools-api": "^6.5.1", "@vue/devtools-api": "^6.5.1",
"@vueuse/core": "^10.7.0", "@vueuse/core": "^10.7.0",
"@vueuse/integrations": "^10.7.0", "@vueuse/integrations": "^10.7.0",
"focus-trap": "^7.5.4", "focus-trap": "^7.5.4",
"mark.js": "8.11.1", "mark.js": "8.11.1",
"minisearch": "^6.3.0", "minisearch": "^6.3.0",
"mrmime": "^1.0.1", "mrmime": "^2.0.0",
"shikiji": "^0.9.7", "shikiji": "^0.9.12",
"shikiji-transformers": "^0.9.7", "shikiji-transformers": "^0.9.12",
"vite": "^5.0.10", "vite": "^5.0.10",
"vue": "^3.3.12" "vue": "^3.4.0-rc.2"
}, },
"peerDependencies": { "peerDependencies": {
"markdown-it-mathjax3": "^4.3.2", "markdown-it-mathjax3": "^4.3.2",
@ -144,16 +144,16 @@
"@types/markdown-it-emoji": "^2.0.4", "@types/markdown-it-emoji": "^2.0.4",
"@types/micromatch": "^4.0.6", "@types/micromatch": "^4.0.6",
"@types/minimist": "^1.2.5", "@types/minimist": "^1.2.5",
"@types/node": "^20.10.4", "@types/node": "^20.10.5",
"@types/postcss-prefix-selector": "^1.16.3", "@types/postcss-prefix-selector": "^1.16.3",
"@types/prompts": "^2.4.9", "@types/prompts": "^2.4.9",
"@vue/shared": "^3.3.12", "@vue/shared": "^3.3.13",
"chokidar": "^3.5.3", "chokidar": "^3.5.3",
"compression": "^1.7.4", "compression": "^1.7.4",
"conventional-changelog-cli": "^4.1.0", "conventional-changelog-cli": "^4.1.0",
"cross-spawn": "^7.0.3", "cross-spawn": "^7.0.3",
"debug": "^4.3.4", "debug": "^4.3.4",
"esbuild": "^0.19.9", "esbuild": "^0.19.10",
"escape-html": "^1.0.3", "escape-html": "^1.0.3",
"execa": "^8.0.1", "execa": "^8.0.1",
"fast-glob": "^3.3.2", "fast-glob": "^3.3.2",
@ -173,7 +173,8 @@
"minimist": "^1.2.8", "minimist": "^1.2.8",
"nanoid": "^5.0.4", "nanoid": "^5.0.4",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"ora": "^7.0.1", "ora": "^8.0.1",
"p-map": "^7.0.0",
"path-to-regexp": "^6.2.1", "path-to-regexp": "^6.2.1",
"picocolors": "^1.0.0", "picocolors": "^1.0.0",
"pkg-dir": "^8.0.0", "pkg-dir": "^8.0.0",
@ -184,18 +185,18 @@
"prompts": "^2.4.2", "prompts": "^2.4.2",
"punycode": "^2.3.1", "punycode": "^2.3.1",
"rimraf": "^5.0.5", "rimraf": "^5.0.5",
"rollup": "^4.9.0", "rollup": "^4.9.1",
"rollup-plugin-dts": "^6.1.0", "rollup-plugin-dts": "^6.1.0",
"rollup-plugin-esbuild": "^6.1.0", "rollup-plugin-esbuild": "^6.1.0",
"semver": "^7.5.4", "semver": "^7.5.4",
"shikiji-core": "^0.9.7", "shikiji-core": "^0.9.12",
"simple-git-hooks": "^2.9.0", "simple-git-hooks": "^2.9.0",
"sirv": "^2.0.3", "sirv": "^2.0.4",
"sitemap": "^7.1.1", "sitemap": "^7.1.1",
"supports-color": "^9.4.0", "supports-color": "^9.4.0",
"typescript": "^5.3.3", "typescript": "^5.3.3",
"vitest": "^1.0.4", "vitest": "^1.1.0",
"vue-tsc": "^1.8.25", "vue-tsc": "^1.8.26",
"wait-on": "^7.2.0" "wait-on": "^7.2.0"
}, },
"simple-git-hooks": { "simple-git-hooks": {

File diff suppressed because it is too large Load Diff

@ -16,13 +16,15 @@ export function useCopyCode() {
parent.className parent.className
) )
let text = '' const ignoredNodes = ['.vp-copy-ignore', '.diff.remove']
sibling // Clone the node and remove the ignored nodes
.querySelectorAll('span.line:not(.diff.remove)') const clone = sibling.cloneNode(true) as HTMLElement
.forEach((node) => (text += (node.textContent || '') + '\n')) clone
.querySelectorAll(ignoredNodes.join(','))
.forEach((node) => node.remove())
text = (text || sibling.textContent || '').slice(0, -1) let text = clone.textContent || ''
if (isShell) { if (isShell) {
text = text.replace(/^ *(\$|>) /gm, '').trim() text = text.replace(/^ *(\$|>) /gm, '').trim()

@ -42,7 +42,11 @@ async function update() {
} }
function initialize(userOptions: DefaultTheme.AlgoliaSearchOptions) { function initialize(userOptions: DefaultTheme.AlgoliaSearchOptions) {
const options = Object.assign<{}, {}, DocSearchProps>({}, userOptions, { const options = Object.assign<
{},
DefaultTheme.AlgoliaSearchOptions,
Partial<DocSearchProps>
>({}, userOptions, {
container: '#docsearch', container: '#docsearch',
navigator: { navigator: {
@ -69,7 +73,6 @@ function initialize(userOptions: DefaultTheme.AlgoliaSearchOptions) {
}) })
}, },
// @ts-expect-error vue-tsc thinks this should return Vue JSX but it returns the required React one
hitComponent({ hit, children }) { hitComponent({ hit, children }) {
return { return {
__v: null, __v: null,
@ -80,7 +83,7 @@ function initialize(userOptions: DefaultTheme.AlgoliaSearchOptions) {
props: { href: hit.url, children } props: { href: hit.url, children }
} }
} }
}) }) as DocSearchProps
docsearch(options) docsearch(options)
} }

@ -4,7 +4,6 @@ import {
computedAsync, computedAsync,
debouncedWatch, debouncedWatch,
onKeyStroke, onKeyStroke,
reactify,
useEventListener, useEventListener,
useLocalStorage, useLocalStorage,
useScrollLock, useScrollLock,
@ -23,7 +22,6 @@ import {
onMounted, onMounted,
ref, ref,
shallowRef, shallowRef,
toRef,
watch, watch,
watchEffect, watchEffect,
type Ref type Ref
@ -32,7 +30,7 @@ import type { ModalTranslations } from '../../../../types/local-search'
import { pathToFile } from '../../app/utils' import { pathToFile } from '../../app/utils'
import { useData } from '../composables/data' import { useData } from '../composables/data'
import { LRUCache } from '../support/lru' import { LRUCache } from '../support/lru'
import { createTranslate } from '../support/translation' import { createSearchTranslate } from '../support/translation'
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'close'): void (e: 'close'): void
@ -361,10 +359,7 @@ const defaultTranslations: { modal: ModalTranslations } = {
} }
} }
const $t = reactify(createTranslate)( const $t = createSearchTranslate(defaultTranslations)
toRef(() => theme.value.search?.options),
defaultTranslations
)
// Back // Back

@ -1,11 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { reactify } from '@vueuse/core'
import { toRef } from 'vue'
import type { ButtonTranslations } from '../../../../types/local-search' import type { ButtonTranslations } from '../../../../types/local-search'
import { useData } from '../composables/data' import { createSearchTranslate } from '../support/translation'
import { createTranslate } from '../support/translation'
const { theme } = useData()
// Button-Translations // Button-Translations
const defaultTranslations: { button: ButtonTranslations } = { const defaultTranslations: { button: ButtonTranslations } = {
@ -15,10 +10,7 @@ const defaultTranslations: { button: ButtonTranslations } = {
} }
} }
const $t = reactify(createTranslate)( const $t = createSearchTranslate(defaultTranslations)
toRef(() => theme.value.search?.options),
defaultTranslations
)
</script> </script>
<template> <template>

@ -47,7 +47,7 @@ withDefaults(defineProps<Props>(), {
</div> </div>
<div v-if="member.sponsor" class="sp"> <div v-if="member.sponsor" class="sp">
<VPLink class="sp-link" :href="member.sponsor" no-icon> <VPLink class="sp-link" :href="member.sponsor" no-icon>
<VPIconHeart class="sp-icon" /> Sponsor <VPIconHeart class="sp-icon" /> {{ member.actionText || 'Sponsor' }}
</VPLink> </VPLink>
</div> </div>
</article> </article>

@ -3,14 +3,14 @@ import { useData } from '../composables/data'
/** /**
* @param themeObject Can be an object with `translations` and `locales` properties * @param themeObject Can be an object with `translations` and `locales` properties
*/ */
export function createTranslate( export function createSearchTranslate(
themeObject: any,
defaultTranslations: Record<string, any> defaultTranslations: Record<string, any>
): (key: string) => string { ): (key: string) => string {
const { localeIndex } = useData() const { localeIndex, theme } = useData()
function translate(key: string): string { function translate(key: string): string {
const keyPath = key.split('.') const keyPath = key.split('.')
const themeObject = theme.value.search?.options
const isObject = themeObject && typeof themeObject === 'object' const isObject = themeObject && typeof themeObject === 'object'
const locales = const locales =

@ -1,12 +1,14 @@
import { createHash } from 'crypto' import { createHash } from 'crypto'
import fs from 'fs-extra' import fs from 'fs-extra'
import { createRequire } from 'module' import { createRequire } from 'module'
import pMap from 'p-map'
import path from 'path' import path from 'path'
import { packageDirectorySync } from 'pkg-dir' import { packageDirectorySync } from 'pkg-dir'
import { rimraf } from 'rimraf' import { rimraf } from 'rimraf'
import { pathToFileURL } from 'url' import { pathToFileURL } from 'url'
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 { slash, type HeadConfig } from '../shared' import { slash, 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'
@ -106,23 +108,23 @@ export async function build(
} }
} }
await Promise.all( await pMap(
['404.md', ...siteConfig.pages] ['404.md', ...siteConfig.pages],
.map((page) => siteConfig.rewrites.map[page] || page) async (page) => {
.map((page) => await renderPage(
renderPage( render,
render, siteConfig,
siteConfig, siteConfig.rewrites.map[page] || page,
page, clientResult,
clientResult, appChunk,
appChunk, cssChunk,
cssChunk, assets,
assets, pageToHashMap,
pageToHashMap, metadataScript,
metadataScript, additionalHeadTags
additionalHeadTags
)
) )
},
{ concurrency: siteConfig.buildConcurrency }
) )
}) })
@ -139,6 +141,7 @@ export async function build(
await generateSitemap(siteConfig) await generateSitemap(siteConfig)
await siteConfig.buildEnd?.(siteConfig) await siteConfig.buildEnd?.(siteConfig)
clearCache()
siteConfig.logger.info( siteConfig.logger.info(
`build complete in ${((Date.now() - start) / 1000).toFixed(2)}s.` `build complete in ${((Date.now() - start) / 1000).toFixed(2)}s.`

@ -141,7 +141,8 @@ export async function resolveConfig(
transformPageData: userConfig.transformPageData, transformPageData: userConfig.transformPageData,
rewrites, rewrites,
userConfig, userConfig,
sitemap: userConfig.sitemap sitemap: userConfig.sitemap,
buildConcurrency: userConfig.buildConcurrency ?? 64
} }
// to be shared with content loaders // to be shared with content loaders

@ -152,7 +152,8 @@ export async function createVitePressPlugin(
site.themeConfig?.search?.provider === 'algolia' || site.themeConfig?.search?.provider === 'algolia' ||
!!site.themeConfig?.algolia, // legacy !!site.themeConfig?.algolia, // legacy
__CARBON__: !!site.themeConfig?.carbonAds, __CARBON__: !!site.themeConfig?.carbonAds,
__ASSETS_DIR__: JSON.stringify(siteConfig.assetsDir) __ASSETS_DIR__: JSON.stringify(siteConfig.assetsDir),
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: !!process.env.DEBUG
}, },
optimizeDeps: { optimizeDeps: {
// force include vue to avoid duplicated copies when linked + optimized // force include vue to avoid duplicated copies when linked + optimized

@ -147,6 +147,15 @@ export interface UserConfig<ThemeConfig = any>
*/ */
useWebFonts?: boolean useWebFonts?: boolean
/**
* This option allows you to configure the concurrency of the build.
* A lower number will reduce the memory usage but will increase the build time.
*
* @experimental
* @default 64
*/
buildConcurrency?: number
/** /**
* @experimental * @experimental
* *
@ -240,4 +249,5 @@ export interface SiteConfig<ThemeConfig = any>
} }
logger: Logger logger: Logger
userConfig: UserConfig userConfig: UserConfig
buildConcurrency: number
} }

@ -113,6 +113,10 @@ export function createTitle(siteData: SiteData, pageData: PageData): string {
const templateString = createTitleTemplate(siteData.title, template) const templateString = createTitleTemplate(siteData.title, template)
if (title === templateString.slice(3)) {
return title
}
return `${title}${templateString}` return `${title}${templateString}`
} }

@ -345,6 +345,7 @@ export namespace DefaultTheme {
desc?: string desc?: string
links?: SocialLink[] links?: SocialLink[]
sponsor?: string sponsor?: string
actionText?: string
} }
// outline ------------------------------------------------------------------- // outline -------------------------------------------------------------------

Loading…
Cancel
Save