From d015cddb30e70580d7628ac99ed62c0e46e1eff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=BD=E5=AE=81?= Date: Wed, 26 Jul 2023 10:45:40 +0800 Subject: [PATCH 001/516] chore(vite): support define replacement without removing double quotes (#2677) --- package.json | 4 ++-- pnpm-lock.yaml | 20 +++++++++++--------- src/client/app/utils.ts | 5 +---- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 7edb26f0..a2790139 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.0-beta.6", "description": "Vite & Vue powered static site generator", "type": "module", - "packageManager": "pnpm@8.6.9", + "packageManager": "pnpm@8.6.10", "main": "dist/node/index.js", "types": "types/index.d.ts", "exports": { @@ -102,7 +102,7 @@ "mark.js": "8.11.1", "minisearch": "^6.1.0", "shiki": "^0.14.3", - "vite": "^4.4.6", + "vite": "^4.4.7", "vue": "^3.3.4" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0b0c7345..6837cc01 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,7 +16,7 @@ importers: version: 3.5.1(@algolia/client-search@4.19.1)(search-insights@2.7.0) '@vitejs/plugin-vue': specifier: ^4.2.3 - version: 4.2.3(vite@4.4.6)(vue@3.3.4) + version: 4.2.3(vite@4.4.7)(vue@3.3.4) '@vue/devtools-api': specifier: ^6.5.0 version: 6.5.0 @@ -42,8 +42,8 @@ importers: specifier: ^0.14.3 version: 0.14.3 vite: - specifier: ^4.4.6 - version: 4.4.6(@types/node@20.4.3) + specifier: ^4.4.7 + version: 4.4.7(@types/node@20.4.3) vue: specifier: ^3.3.4 version: 3.3.4 @@ -446,6 +446,7 @@ packages: /@babel/highlight@7.22.5: resolution: {integrity: sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw==} engines: {node: '>=6.9.0'} + requiresBuild: true dependencies: '@babel/helper-validator-identifier': 7.22.5 chalk: 2.4.2 @@ -1149,14 +1150,14 @@ packages: resolution: {integrity: sha512-4p9vcSmxAayx72yn70joFoL44c9MO/0+iVEBIQXe3v2h2SiAsEIo/G5v6ObFWvNKRFjbrVadNf9LqEEZeQPzdA==} dev: false - /@vitejs/plugin-vue@4.2.3(vite@4.4.6)(vue@3.3.4): + /@vitejs/plugin-vue@4.2.3(vite@4.4.7)(vue@3.3.4): resolution: {integrity: sha512-R6JDUfiZbJA9cMiguQ7jxALsgiprjBeHL5ikpXfJCH62pPHtI+JdJ5xWj6Ev73yXSlYl86+blXn1kZHQ7uElxw==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: vite: ^4.0.0 vue: ^3.2.25 dependencies: - vite: 4.4.6(@types/node@20.4.3) + vite: 4.4.7(@types/node@20.4.3) vue: 3.3.4 dev: false @@ -2886,6 +2887,7 @@ packages: /js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + requiresBuild: true dev: true /js-yaml@3.14.1: @@ -4457,7 +4459,7 @@ packages: mlly: 1.4.0 pathe: 1.1.1 picocolors: 1.0.0 - vite: 4.4.6(@types/node@20.4.3) + vite: 4.4.7(@types/node@20.4.3) transitivePeerDependencies: - '@types/node' - less @@ -4469,8 +4471,8 @@ packages: - terser dev: true - /vite@4.4.6(@types/node@20.4.3): - resolution: {integrity: sha512-EY6Mm8vJ++S3D4tNAckaZfw3JwG3wa794Vt70M6cNJ6NxT87yhq7EC8Rcap3ahyHdo8AhCmV9PTk+vG1HiYn1A==} + /vite@4.4.7(@types/node@20.4.3): + resolution: {integrity: sha512-6pYf9QJ1mHylfVh39HpuSfMPojPSKVxZvnclX1K1FyZ1PXDOcLBibdq5t1qxJSnL63ca8Wf4zts6mD8u8oc9Fw==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true peerDependencies: @@ -4556,7 +4558,7 @@ packages: strip-literal: 1.0.1 tinybench: 2.5.0 tinypool: 0.6.0 - vite: 4.4.6(@types/node@20.4.3) + vite: 4.4.7(@types/node@20.4.3) vite-node: 0.33.0(@types/node@20.4.3)(supports-color@9.4.0) why-is-node-running: 2.2.2 transitivePeerDependencies: diff --git a/src/client/app/utils.ts b/src/client/app/utils.ts index 9a5fb483..9935284d 100644 --- a/src/client/app/utils.ts +++ b/src/client/app/utils.ts @@ -58,10 +58,7 @@ export function pathToFile(path: string) { pageHash = __VP_HASH_MAP__[pagePath.toLowerCase()] } if (!pageHash) return null - pagePath = `${base}${__ASSETS_DIR__.replace( - /"(.+)"/, - '$1' - )}/${pagePath}.${pageHash}.js` + pagePath = `${base}${__ASSETS_DIR__}/${pagePath}.${pageHash}.js` } else { // ssr build uses much simpler name mapping pagePath = `./${sanitizeFileName( From fb048a6f7289a12a8e67724cee29e55252568489 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Wed, 26 Jul 2023 08:40:34 +0530 Subject: [PATCH 002/516] fix(search): add useFocusTrap and mark.js to optimizeDeps (#2682) --- .../e2e/local-search/local-search.test.ts | 3 - package.json | 10 +- pnpm-lock.yaml | 256 +++++++++--------- src/node/plugins/localSearchPlugin.ts | 5 +- 4 files changed, 135 insertions(+), 139 deletions(-) diff --git a/__tests__/e2e/local-search/local-search.test.ts b/__tests__/e2e/local-search/local-search.test.ts index bea2c6b9..492136b6 100644 --- a/__tests__/e2e/local-search/local-search.test.ts +++ b/__tests__/e2e/local-search/local-search.test.ts @@ -1,9 +1,6 @@ describe('local search', () => { beforeEach(async () => { await goto('/') - // FIXME: remove this when optimizeDeps.include is fixed - await page.locator('#local-search button').click() - await goto('/') }) test('exclude content from search results', async () => { diff --git a/package.json b/package.json index a2790139..0c14c675 100644 --- a/package.json +++ b/package.json @@ -128,11 +128,11 @@ "@types/mark.js": "^8.11.8", "@types/markdown-it": "^12.2.3", "@types/markdown-it-attrs": "^4.1.0", - "@types/markdown-it-container": "^2.0.5", + "@types/markdown-it-container": "^2.0.6", "@types/markdown-it-emoji": "^2.0.2", "@types/micromatch": "^4.0.2", "@types/minimist": "^1.2.2", - "@types/node": "^20.4.3", + "@types/node": "^20.4.5", "@types/prompts": "^2.4.4", "@vue/shared": "^3.3.4", "chokidar": "^3.5.3", @@ -140,7 +140,7 @@ "conventional-changelog-cli": "^2", "cross-spawn": "^7.0.3", "debug": "^4.3.4", - "esbuild": "^0.18.15", + "esbuild": "^0.18.17", "escape-html": "^1.0.3", "execa": "^7.1.1", "fast-glob": "^3.3.1", @@ -163,7 +163,7 @@ "path-to-regexp": "^6.2.1", "picocolors": "^1.0.0", "pkg-dir": "^7.0.0", - "playwright-chromium": "^1.36.1", + "playwright-chromium": "^1.36.2", "polka": "1.0.0-next.22", "prettier": "^3.0.0", "prompts": "^2.4.2", @@ -174,7 +174,7 @@ "rollup-plugin-esbuild": "^5.0.0", "semver": "^7.5.4", "shiki-processor": "^0.1.3", - "simple-git-hooks": "^2.8.1", + "simple-git-hooks": "^2.9.0", "sirv": "^2.0.3", "supports-color": "^9.4.0", "typescript": "^5.1.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6837cc01..2d85eb2f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -43,7 +43,7 @@ importers: version: 0.14.3 vite: specifier: ^4.4.7 - version: 4.4.7(@types/node@20.4.3) + version: 4.4.7(@types/node@20.4.5) vue: specifier: ^3.3.4 version: 3.3.4 @@ -115,8 +115,8 @@ importers: specifier: ^4.1.0 version: 4.1.0 '@types/markdown-it-container': - specifier: ^2.0.5 - version: 2.0.5 + specifier: ^2.0.6 + version: 2.0.6 '@types/markdown-it-emoji': specifier: ^2.0.2 version: 2.0.2 @@ -127,8 +127,8 @@ importers: specifier: ^1.2.2 version: 1.2.2 '@types/node': - specifier: ^20.4.3 - version: 20.4.3 + specifier: ^20.4.5 + version: 20.4.5 '@types/prompts': specifier: ^2.4.4 version: 2.4.4 @@ -151,8 +151,8 @@ importers: specifier: ^4.3.4 version: 4.3.4(supports-color@9.4.0) esbuild: - specifier: ^0.18.15 - version: 0.18.15 + specifier: ^0.18.17 + version: 0.18.17 escape-html: specifier: ^1.0.3 version: 1.0.3 @@ -220,8 +220,8 @@ importers: specifier: ^7.0.0 version: 7.0.0 playwright-chromium: - specifier: ^1.36.1 - version: 1.36.1 + specifier: ^1.36.2 + version: 1.36.2 polka: specifier: 1.0.0-next.22 version: 1.0.0-next.22 @@ -245,7 +245,7 @@ importers: version: 5.3.0(rollup@3.26.3)(typescript@5.1.6) rollup-plugin-esbuild: specifier: ^5.0.0 - version: 5.0.0(esbuild@0.18.15)(rollup@3.26.3)(supports-color@9.4.0) + version: 5.0.0(esbuild@0.18.17)(rollup@3.26.3)(supports-color@9.4.0) semver: specifier: ^7.5.4 version: 7.5.4 @@ -253,8 +253,8 @@ importers: specifier: ^0.1.3 version: 0.1.3(shiki@0.14.3) simple-git-hooks: - specifier: ^2.8.1 - version: 2.8.1 + specifier: ^2.9.0 + version: 2.9.0 sirv: specifier: ^2.0.3 version: 2.0.3 @@ -525,176 +525,176 @@ packages: - search-insights dev: false - /@esbuild/android-arm64@0.18.15: - resolution: {integrity: sha512-NI/gnWcMl2kXt1HJKOn2H69SYn4YNheKo6NZt1hyfKWdMbaGadxjZIkcj4Gjk/WPxnbFXs9/3HjGHaknCqjrww==} + /@esbuild/android-arm64@0.18.17: + resolution: {integrity: sha512-9np+YYdNDed5+Jgr1TdWBsozZ85U1Oa3xW0c7TWqH0y2aGghXtZsuT8nYRbzOMcl0bXZXjOGbksoTtVOlWrRZg==} engines: {node: '>=12'} cpu: [arm64] os: [android] requiresBuild: true optional: true - /@esbuild/android-arm@0.18.15: - resolution: {integrity: sha512-wlkQBWb79/jeEEoRmrxt/yhn5T1lU236OCNpnfRzaCJHZ/5gf82uYx1qmADTBWE0AR/v7FiozE1auk2riyQd3w==} + /@esbuild/android-arm@0.18.17: + resolution: {integrity: sha512-wHsmJG/dnL3OkpAcwbgoBTTMHVi4Uyou3F5mf58ZtmUyIKfcdA7TROav/6tCzET4A3QW2Q2FC+eFneMU+iyOxg==} engines: {node: '>=12'} cpu: [arm] os: [android] requiresBuild: true optional: true - /@esbuild/android-x64@0.18.15: - resolution: {integrity: sha512-FM9NQamSaEm/IZIhegF76aiLnng1kEsZl2eve/emxDeReVfRuRNmvT28l6hoFD9TsCxpK+i4v8LPpEj74T7yjA==} + /@esbuild/android-x64@0.18.17: + resolution: {integrity: sha512-O+FeWB/+xya0aLg23hHEM2E3hbfwZzjqumKMSIqcHbNvDa+dza2D0yLuymRBQQnC34CWrsJUXyH2MG5VnLd6uw==} engines: {node: '>=12'} cpu: [x64] os: [android] requiresBuild: true optional: true - /@esbuild/darwin-arm64@0.18.15: - resolution: {integrity: sha512-XmrFwEOYauKte9QjS6hz60FpOCnw4zaPAb7XV7O4lx1r39XjJhTN7ZpXqJh4sN6q60zbP6QwAVVA8N/wUyBH/w==} + /@esbuild/darwin-arm64@0.18.17: + resolution: {integrity: sha512-M9uJ9VSB1oli2BE/dJs3zVr9kcCBBsE883prage1NWz6pBS++1oNn/7soPNS3+1DGj0FrkSvnED4Bmlu1VAE9g==} engines: {node: '>=12'} cpu: [arm64] os: [darwin] requiresBuild: true optional: true - /@esbuild/darwin-x64@0.18.15: - resolution: {integrity: sha512-bMqBmpw1e//7Fh5GLetSZaeo9zSC4/CMtrVFdj+bqKPGJuKyfNJ5Nf2m3LknKZTS+Q4oyPiON+v3eaJ59sLB5A==} + /@esbuild/darwin-x64@0.18.17: + resolution: {integrity: sha512-XDre+J5YeIJDMfp3n0279DFNrGCXlxOuGsWIkRb1NThMZ0BsrWXoTg23Jer7fEXQ9Ye5QjrvXpxnhzl3bHtk0g==} engines: {node: '>=12'} cpu: [x64] os: [darwin] requiresBuild: true optional: true - /@esbuild/freebsd-arm64@0.18.15: - resolution: {integrity: sha512-LoTK5N3bOmNI9zVLCeTgnk5Rk0WdUTrr9dyDAQGVMrNTh9EAPuNwSTCgaKOKiDpverOa0htPcO9NwslSE5xuLA==} + /@esbuild/freebsd-arm64@0.18.17: + resolution: {integrity: sha512-cjTzGa3QlNfERa0+ptykyxs5A6FEUQQF0MuilYXYBGdBxD3vxJcKnzDlhDCa1VAJCmAxed6mYhA2KaJIbtiNuQ==} engines: {node: '>=12'} cpu: [arm64] os: [freebsd] requiresBuild: true optional: true - /@esbuild/freebsd-x64@0.18.15: - resolution: {integrity: sha512-62jX5n30VzgrjAjOk5orYeHFq6sqjvsIj1QesXvn5OZtdt5Gdj0vUNJy9NIpjfdNdqr76jjtzBJKf+h2uzYuTQ==} + /@esbuild/freebsd-x64@0.18.17: + resolution: {integrity: sha512-sOxEvR8d7V7Kw8QqzxWc7bFfnWnGdaFBut1dRUYtu+EIRXefBc/eIsiUiShnW0hM3FmQ5Zf27suDuHsKgZ5QrA==} engines: {node: '>=12'} cpu: [x64] os: [freebsd] requiresBuild: true optional: true - /@esbuild/linux-arm64@0.18.15: - resolution: {integrity: sha512-BWncQeuWDgYv0jTNzJjaNgleduV4tMbQjmk/zpPh/lUdMcNEAxy+jvneDJ6RJkrqloG7tB9S9rCrtfk/kuplsQ==} + /@esbuild/linux-arm64@0.18.17: + resolution: {integrity: sha512-c9w3tE7qA3CYWjT+M3BMbwMt+0JYOp3vCMKgVBrCl1nwjAlOMYzEo+gG7QaZ9AtqZFj5MbUc885wuBBmu6aADQ==} engines: {node: '>=12'} cpu: [arm64] os: [linux] requiresBuild: true optional: true - /@esbuild/linux-arm@0.18.15: - resolution: {integrity: sha512-dT4URUv6ir45ZkBqhwZwyFV6cH61k8MttIwhThp2BGiVtagYvCToF+Bggyx2VI57RG4Fbt21f9TmXaYx0DeUJg==} + /@esbuild/linux-arm@0.18.17: + resolution: {integrity: sha512-2d3Lw6wkwgSLC2fIvXKoMNGVaeY8qdN0IC3rfuVxJp89CRfA3e3VqWifGDfuakPmp90+ZirmTfye1n4ncjv2lg==} engines: {node: '>=12'} cpu: [arm] os: [linux] requiresBuild: true optional: true - /@esbuild/linux-ia32@0.18.15: - resolution: {integrity: sha512-JPXORvgHRHITqfms1dWT/GbEY89u848dC08o0yK3fNskhp0t2TuNUnsrrSgOdH28ceb1hJuwyr8R/1RnyPwocw==} + /@esbuild/linux-ia32@0.18.17: + resolution: {integrity: sha512-1DS9F966pn5pPnqXYz16dQqWIB0dmDfAQZd6jSSpiT9eX1NzKh07J6VKR3AoXXXEk6CqZMojiVDSZi1SlmKVdg==} engines: {node: '>=12'} cpu: [ia32] os: [linux] requiresBuild: true optional: true - /@esbuild/linux-loong64@0.18.15: - resolution: {integrity: sha512-kArPI0DopjJCEplsVj/H+2Qgzz7vdFSacHNsgoAKpPS6W/Ndh8Oe24HRDQ5QCu4jHgN6XOtfFfLpRx3TXv/mEg==} + /@esbuild/linux-loong64@0.18.17: + resolution: {integrity: sha512-EvLsxCk6ZF0fpCB6w6eOI2Fc8KW5N6sHlIovNe8uOFObL2O+Mr0bflPHyHwLT6rwMg9r77WOAWb2FqCQrVnwFg==} engines: {node: '>=12'} cpu: [loong64] os: [linux] requiresBuild: true optional: true - /@esbuild/linux-mips64el@0.18.15: - resolution: {integrity: sha512-b/tmngUfO02E00c1XnNTw/0DmloKjb6XQeqxaYuzGwHe0fHVgx5/D6CWi+XH1DvkszjBUkK9BX7n1ARTOst59w==} + /@esbuild/linux-mips64el@0.18.17: + resolution: {integrity: sha512-e0bIdHA5p6l+lwqTE36NAW5hHtw2tNRmHlGBygZC14QObsA3bD4C6sXLJjvnDIjSKhW1/0S3eDy+QmX/uZWEYQ==} engines: {node: '>=12'} cpu: [mips64el] os: [linux] requiresBuild: true optional: true - /@esbuild/linux-ppc64@0.18.15: - resolution: {integrity: sha512-KXPY69MWw79QJkyvUYb2ex/OgnN/8N/Aw5UDPlgoRtoEfcBqfeLodPr42UojV3NdkoO4u10NXQdamWm1YEzSKw==} + /@esbuild/linux-ppc64@0.18.17: + resolution: {integrity: sha512-BAAilJ0M5O2uMxHYGjFKn4nJKF6fNCdP1E0o5t5fvMYYzeIqy2JdAP88Az5LHt9qBoUa4tDaRpfWt21ep5/WqQ==} engines: {node: '>=12'} cpu: [ppc64] os: [linux] requiresBuild: true optional: true - /@esbuild/linux-riscv64@0.18.15: - resolution: {integrity: sha512-komK3NEAeeGRnvFEjX1SfVg6EmkfIi5aKzevdvJqMydYr9N+pRQK0PGJXk+bhoPZwOUgLO4l99FZmLGk/L1jWg==} + /@esbuild/linux-riscv64@0.18.17: + resolution: {integrity: sha512-Wh/HW2MPnC3b8BqRSIme/9Zhab36PPH+3zam5pqGRH4pE+4xTrVLx2+XdGp6fVS3L2x+DrsIcsbMleex8fbE6g==} engines: {node: '>=12'} cpu: [riscv64] os: [linux] requiresBuild: true optional: true - /@esbuild/linux-s390x@0.18.15: - resolution: {integrity: sha512-632T5Ts6gQ2WiMLWRRyeflPAm44u2E/s/TJvn+BP6M5mnHSk93cieaypj3VSMYO2ePTCRqAFXtuYi1yv8uZJNA==} + /@esbuild/linux-s390x@0.18.17: + resolution: {integrity: sha512-j/34jAl3ul3PNcK3pfI0NSlBANduT2UO5kZ7FCaK33XFv3chDhICLY8wJJWIhiQ+YNdQ9dxqQctRg2bvrMlYgg==} engines: {node: '>=12'} cpu: [s390x] os: [linux] requiresBuild: true optional: true - /@esbuild/linux-x64@0.18.15: - resolution: {integrity: sha512-MsHtX0NgvRHsoOtYkuxyk4Vkmvk3PLRWfA4okK7c+6dT0Fu4SUqXAr9y4Q3d8vUf1VWWb6YutpL4XNe400iQ1g==} + /@esbuild/linux-x64@0.18.17: + resolution: {integrity: sha512-QM50vJ/y+8I60qEmFxMoxIx4de03pGo2HwxdBeFd4nMh364X6TIBZ6VQ5UQmPbQWUVWHWws5MmJXlHAXvJEmpQ==} engines: {node: '>=12'} cpu: [x64] os: [linux] requiresBuild: true optional: true - /@esbuild/netbsd-x64@0.18.15: - resolution: {integrity: sha512-djST6s+jQiwxMIVQ5rlt24JFIAr4uwUnzceuFL7BQT4CbrRtqBPueS4GjXSiIpmwVri1Icj/9pFRJ7/aScvT+A==} + /@esbuild/netbsd-x64@0.18.17: + resolution: {integrity: sha512-/jGlhWR7Sj9JPZHzXyyMZ1RFMkNPjC6QIAan0sDOtIo2TYk3tZn5UDrkE0XgsTQCxWTTOcMPf9p6Rh2hXtl5TQ==} engines: {node: '>=12'} cpu: [x64] os: [netbsd] requiresBuild: true optional: true - /@esbuild/openbsd-x64@0.18.15: - resolution: {integrity: sha512-naeRhUIvhsgeounjkF5mvrNAVMGAm6EJWiabskeE5yOeBbLp7T89tAEw0j5Jm/CZAwyLe3c67zyCWH6fsBLCpw==} + /@esbuild/openbsd-x64@0.18.17: + resolution: {integrity: sha512-rSEeYaGgyGGf4qZM2NonMhMOP/5EHp4u9ehFiBrg7stH6BYEEjlkVREuDEcQ0LfIl53OXLxNbfuIj7mr5m29TA==} engines: {node: '>=12'} cpu: [x64] os: [openbsd] requiresBuild: true optional: true - /@esbuild/sunos-x64@0.18.15: - resolution: {integrity: sha512-qkT2+WxyKbNIKV1AEhI8QiSIgTHMcRctzSaa/I3kVgMS5dl3fOeoqkb7pW76KwxHoriImhx7Mg3TwN/auMDsyQ==} + /@esbuild/sunos-x64@0.18.17: + resolution: {integrity: sha512-Y7ZBbkLqlSgn4+zot4KUNYst0bFoO68tRgI6mY2FIM+b7ZbyNVtNbDP5y8qlu4/knZZ73fgJDlXID+ohY5zt5g==} engines: {node: '>=12'} cpu: [x64] os: [sunos] requiresBuild: true optional: true - /@esbuild/win32-arm64@0.18.15: - resolution: {integrity: sha512-HC4/feP+pB2Vb+cMPUjAnFyERs+HJN7E6KaeBlFdBv799MhD+aPJlfi/yk36SED58J9TPwI8MAcVpJgej4ud0A==} + /@esbuild/win32-arm64@0.18.17: + resolution: {integrity: sha512-bwPmTJsEQcbZk26oYpc4c/8PvTY3J5/QK8jM19DVlEsAB41M39aWovWoHtNm78sd6ip6prilxeHosPADXtEJFw==} engines: {node: '>=12'} cpu: [arm64] os: [win32] requiresBuild: true optional: true - /@esbuild/win32-ia32@0.18.15: - resolution: {integrity: sha512-ovjwoRXI+gf52EVF60u9sSDj7myPixPxqzD5CmkEUmvs+W9Xd0iqISVBQn8xcx4ciIaIVlWCuTbYDOXOnOL44Q==} + /@esbuild/win32-ia32@0.18.17: + resolution: {integrity: sha512-H/XaPtPKli2MhW+3CQueo6Ni3Avggi6hP/YvgkEe1aSaxw+AeO8MFjq8DlgfTd9Iz4Yih3QCZI6YLMoyccnPRg==} engines: {node: '>=12'} cpu: [ia32] os: [win32] requiresBuild: true optional: true - /@esbuild/win32-x64@0.18.15: - resolution: {integrity: sha512-imUxH9a3WJARyAvrG7srLyiK73XdX83NXQkjKvQ+7vPh3ZxoLrzvPkQKKw2DwZ+RV2ZB6vBfNHP8XScAmQC3aA==} + /@esbuild/win32-x64@0.18.17: + resolution: {integrity: sha512-fGEb8f2BSA3CW7riJVurug65ACLuQAzKq0SSqkY2b2yHHH0MzDfbLyKIGzHwOI/gkHcxM/leuSW6D5w/LMNitA==} engines: {node: '>=12'} cpu: [x64] os: [win32] @@ -946,7 +946,7 @@ packages: resolution: {integrity: sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==} dependencies: '@types/connect': 3.4.35 - '@types/node': 20.4.3 + '@types/node': 20.4.5 dev: true /@types/body-scroll-lock@3.1.0: @@ -976,13 +976,13 @@ packages: /@types/connect@3.4.35: resolution: {integrity: sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==} dependencies: - '@types/node': 20.4.3 + '@types/node': 20.4.5 dev: true /@types/cross-spawn@6.0.2: resolution: {integrity: sha512-KuwNhp3eza+Rhu8IFI5HUXRP0LIhqH5cAjubUvGXXthh4YYBuP2ntwEX+Cz8GJoZUHlKo247wPWOfA9LYEq4cw==} dependencies: - '@types/node': 20.4.3 + '@types/node': 20.4.5 dev: true /@types/debug@4.1.8: @@ -1002,7 +1002,7 @@ packages: /@types/express-serve-static-core@4.17.35: resolution: {integrity: sha512-wALWQwrgiB2AWTT91CB62b6Yt0sNHpznUXeZEcnPU3DRdlDIz74x8Qg1UUYKSVFi+va5vKOLYRBI1bRKiLLKIg==} dependencies: - '@types/node': 20.4.3 + '@types/node': 20.4.5 '@types/qs': 6.9.7 '@types/range-parser': 1.2.4 '@types/send': 0.17.1 @@ -1021,7 +1021,7 @@ packages: resolution: {integrity: sha512-MxObHvNl4A69ofaTRU8DFqvgzzv8s9yRtaPPm5gud9HDNvpB3GPQFvNuTWAI59B9huVGV5jXYJwbCsmBsOGYWA==} dependencies: '@types/jsonfile': 6.1.1 - '@types/node': 20.4.3 + '@types/node': 20.4.5 dev: true /@types/http-errors@2.0.1: @@ -1037,7 +1037,7 @@ packages: /@types/jsonfile@6.1.1: resolution: {integrity: sha512-GSgiRCVeapDN+3pqA35IkQwasaCh/0YFH5dEF6S88iDvEn901DjOeH3/QPY+XYP1DFzDZPvIvfeEgk+7br5png==} dependencies: - '@types/node': 20.4.3 + '@types/node': 20.4.5 dev: true /@types/linkify-it@3.0.2: @@ -1056,8 +1056,8 @@ packages: '@types/markdown-it': 12.2.3 dev: true - /@types/markdown-it-container@2.0.5: - resolution: {integrity: sha512-8v5jIC5gcCUv+JcD0DExwNBkoKC0kLB4acensF0NoNlTIcXmQxF3RDjzAdIW82sXSoR+n772ePguxIWlq2ELvA==} + /@types/markdown-it-container@2.0.6: + resolution: {integrity: sha512-euUVSCx2+tGV8BlI7yA7AXmNsLzYCoUbg/O2jJ0wzV/0oxKbmd5RJZI2map8cuEKgmjNy13ndFWRZZO+6rl0GA==} dependencies: '@types/markdown-it': 12.2.3 dev: true @@ -1101,8 +1101,8 @@ packages: resolution: {integrity: sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==} dev: true - /@types/node@20.4.3: - resolution: {integrity: sha512-Yu3+r4Mn/iY6Mf0aihncZQ1qOjOUrCiodbHHY1hds5O+7BbKp9t+Li7zLO13zO8j9L2C6euz8xsYQP0rjGvVXw==} + /@types/node@20.4.5: + resolution: {integrity: sha512-rt40Nk13II9JwQBdeYqmbn2Q6IVTA5uPhvSO+JVqdXw/6/4glI6oR9ezty/A9Hg5u7JH4OmYmuQ+XvjKm0Datg==} /@types/normalize-package-data@2.4.1: resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} @@ -1111,7 +1111,7 @@ packages: /@types/prompts@2.4.4: resolution: {integrity: sha512-p5N9uoTH76lLvSAaYSZtBCdEXzpOOufsRjnhjVSrZGXikVGHX9+cc9ERtHRV4hvBKHyZb1bg4K+56Bd2TqUn4A==} dependencies: - '@types/node': 20.4.3 + '@types/node': 20.4.5 kleur: 3.0.3 dev: true @@ -1131,7 +1131,7 @@ packages: resolution: {integrity: sha512-Cwo8LE/0rnvX7kIIa3QHCkcuF21c05Ayb0ZfxPiv0W8VRiZiNW/WuRupHKpqqGVGf7SUA44QSOUKaEd9lIrd/Q==} dependencies: '@types/mime': 1.3.2 - '@types/node': 20.4.3 + '@types/node': 20.4.5 dev: true /@types/serve-static@1.15.2: @@ -1139,7 +1139,7 @@ packages: dependencies: '@types/http-errors': 2.0.1 '@types/mime': 3.0.1 - '@types/node': 20.4.3 + '@types/node': 20.4.5 dev: true /@types/sizzle@2.3.3: @@ -1157,7 +1157,7 @@ packages: vite: ^4.0.0 vue: ^3.2.25 dependencies: - vite: 4.4.7(@types/node@20.4.3) + vite: 4.4.7(@types/node@20.4.5) vue: 3.3.4 dev: false @@ -1199,22 +1199,22 @@ packages: pretty-format: 29.6.1 dev: true - /@volar/language-core@1.9.1: - resolution: {integrity: sha512-FlllCDE0HdUYh66zS1S4u8WobqKFStOwkd3OCXCOhPmalfm4Fte3gHNXzqs+R8VlbjK7ZvBxrG9MSiaRGXZygg==} + /@volar/language-core@1.9.2: + resolution: {integrity: sha512-9GTes/IUPOl0YoV5RQWhCP5a4EDFFfJZGwZn1xA5ug1FO0G6GOVoJI6tQatujtcQmDOQlOM5/0NewnlumygPkQ==} dependencies: - '@volar/source-map': 1.9.1 + '@volar/source-map': 1.9.2 dev: true - /@volar/source-map@1.9.1: - resolution: {integrity: sha512-KIttDVrbr3ACLzEP891uj+XdVaCnNErFNRGjNQio+gW2a9fDdz407usAJu6DHgIkJU1l18HyOxMU2VX1l2+D5g==} + /@volar/source-map@1.9.2: + resolution: {integrity: sha512-rYTvV/HMf2CSRkd6oiVxcjX4rnSxEsVfJmw1KTmD4VTBXlz1+b16VIysQX4+1p/eZd2TyCeFblyylIxbZ+YOGg==} dependencies: muggle-string: 0.3.1 dev: true - /@volar/typescript@1.9.1: - resolution: {integrity: sha512-UO8bhflYMNuOpXeGYHSm3xItU4kEVhJQNGjwgw1ZqLr/sm1C7Y+pVQ/S01NpsojhFC8S+P6/p+jOTK6DO214kQ==} + /@volar/typescript@1.9.2: + resolution: {integrity: sha512-l4DA+S3ZVOWGACDdRNVSYZ41nuTWOH8OMS/yVeFV2fTmr/IuD37+3wzzGnjIPwCUa0w+fpg8vJPalzYetmlFTQ==} dependencies: - '@volar/language-core': 1.9.1 + '@volar/language-core': 1.9.2 dev: true /@vue/compiler-core@3.3.4: @@ -1265,8 +1265,8 @@ packages: typescript: optional: true dependencies: - '@volar/language-core': 1.9.1 - '@volar/source-map': 1.9.1 + '@volar/language-core': 1.9.2 + '@volar/source-map': 1.9.2 '@vue/compiler-dom': 3.3.4 '@vue/reactivity': 3.3.4 '@vue/shared': 3.3.4 @@ -1322,7 +1322,7 @@ packages: /@vue/typescript@1.8.6(typescript@5.1.6): resolution: {integrity: sha512-sDQ5tltrSVS3lAkE3JtMRGJo91CLIxcWPy7yms/DT+ssxXpwxbVRD5Gok68HenEZBA4Klq7nW99sG/nTRnpPuQ==} dependencies: - '@volar/typescript': 1.9.1 + '@volar/typescript': 1.9.2 '@vue/language-core': 1.8.6(typescript@5.1.6) transitivePeerDependencies: - typescript @@ -2214,34 +2214,34 @@ packages: is-symbol: 1.0.4 dev: true - /esbuild@0.18.15: - resolution: {integrity: sha512-3WOOLhrvuTGPRzQPU6waSDWrDTnQriia72McWcn6UCi43GhCHrXH4S59hKMeez+IITmdUuUyvbU9JIp+t3xlPQ==} + /esbuild@0.18.17: + resolution: {integrity: sha512-1GJtYnUxsJreHYA0Y+iQz2UEykonY66HNWOb0yXYZi9/kNrORUEHVg87eQsCtqh59PEJ5YVZJO98JHznMJSWjg==} engines: {node: '>=12'} hasBin: true requiresBuild: true optionalDependencies: - '@esbuild/android-arm': 0.18.15 - '@esbuild/android-arm64': 0.18.15 - '@esbuild/android-x64': 0.18.15 - '@esbuild/darwin-arm64': 0.18.15 - '@esbuild/darwin-x64': 0.18.15 - '@esbuild/freebsd-arm64': 0.18.15 - '@esbuild/freebsd-x64': 0.18.15 - '@esbuild/linux-arm': 0.18.15 - '@esbuild/linux-arm64': 0.18.15 - '@esbuild/linux-ia32': 0.18.15 - '@esbuild/linux-loong64': 0.18.15 - '@esbuild/linux-mips64el': 0.18.15 - '@esbuild/linux-ppc64': 0.18.15 - '@esbuild/linux-riscv64': 0.18.15 - '@esbuild/linux-s390x': 0.18.15 - '@esbuild/linux-x64': 0.18.15 - '@esbuild/netbsd-x64': 0.18.15 - '@esbuild/openbsd-x64': 0.18.15 - '@esbuild/sunos-x64': 0.18.15 - '@esbuild/win32-arm64': 0.18.15 - '@esbuild/win32-ia32': 0.18.15 - '@esbuild/win32-x64': 0.18.15 + '@esbuild/android-arm': 0.18.17 + '@esbuild/android-arm64': 0.18.17 + '@esbuild/android-x64': 0.18.17 + '@esbuild/darwin-arm64': 0.18.17 + '@esbuild/darwin-x64': 0.18.17 + '@esbuild/freebsd-arm64': 0.18.17 + '@esbuild/freebsd-x64': 0.18.17 + '@esbuild/linux-arm': 0.18.17 + '@esbuild/linux-arm64': 0.18.17 + '@esbuild/linux-ia32': 0.18.17 + '@esbuild/linux-loong64': 0.18.17 + '@esbuild/linux-mips64el': 0.18.17 + '@esbuild/linux-ppc64': 0.18.17 + '@esbuild/linux-riscv64': 0.18.17 + '@esbuild/linux-s390x': 0.18.17 + '@esbuild/linux-x64': 0.18.17 + '@esbuild/netbsd-x64': 0.18.17 + '@esbuild/openbsd-x64': 0.18.17 + '@esbuild/sunos-x64': 0.18.17 + '@esbuild/win32-arm64': 0.18.17 + '@esbuild/win32-ia32': 0.18.17 + '@esbuild/win32-x64': 0.18.17 /escalade@3.1.1: resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} @@ -2509,7 +2509,7 @@ packages: hasBin: true dependencies: foreground-child: 3.1.1 - jackspeak: 2.2.1 + jackspeak: 2.2.2 minimatch: 9.0.3 minipass: 7.0.2 path-scurry: 1.10.1 @@ -2861,8 +2861,8 @@ packages: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} dev: true - /jackspeak@2.2.1: - resolution: {integrity: sha512-MXbxovZ/Pm42f6cDIDkl3xpwv1AGwObKwfmjs2nQePiy85tP3fatofl3FC1aBsOtP/6fq5SbtgHwWcMsLP+bDw==} + /jackspeak@2.2.2: + resolution: {integrity: sha512-mgNtVv4vUuaKA97yxUHoA3+FkuhtxkjdXEWOyB/N76fjy0FjezEt34oy3epBtvCvS+7DyKwqCFWx/oJLV5+kCg==} engines: {node: '>=14'} dependencies: '@isaacs/cliui': 8.0.2 @@ -3612,17 +3612,17 @@ packages: pathe: 1.1.1 dev: true - /playwright-chromium@1.36.1: - resolution: {integrity: sha512-V2jBtS5zNUyMajzh6SRiCzafsz/Mg35IroR+SwWhAa1Dqa4juGXDp26AdK7Nj/fAOvwnG+dFDVOVx/ewt9dSxQ==} + /playwright-chromium@1.36.2: + resolution: {integrity: sha512-ONY6+ON1A+qYUBiymWn3MHnBjdPO6lYIi2SiQbUo1OA0cSZaxx9vM2mRYY3p7JLC6AhAbPEimZdXetQx48AHkA==} engines: {node: '>=16'} hasBin: true requiresBuild: true dependencies: - playwright-core: 1.36.1 + playwright-core: 1.36.2 dev: true - /playwright-core@1.36.1: - resolution: {integrity: sha512-7+tmPuMcEW4xeCL9cp9KxmYpQYHKkyjwoXRnoeTowaeNat8PoBMk/HwCYhqkH2fRkshfKEOiVus/IhID2Pg8kg==} + /playwright-core@1.36.2: + resolution: {integrity: sha512-sQYZt31dwkqxOrP7xy2ggDfEzUxM1lodjhsQ3NMMv5uGTRDsLxU0e4xf4wwMkF2gplIxf17QMBCodSFgm6bFVQ==} engines: {node: '>=16'} hasBin: true dev: true @@ -3844,7 +3844,7 @@ packages: '@babel/code-frame': 7.22.5 dev: true - /rollup-plugin-esbuild@5.0.0(esbuild@0.18.15)(rollup@3.26.3)(supports-color@9.4.0): + /rollup-plugin-esbuild@5.0.0(esbuild@0.18.17)(rollup@3.26.3)(supports-color@9.4.0): resolution: {integrity: sha512-1cRIOHAPh8WQgdQQyyvFdeOdxuiyk+zB5zJ5+YOwrZP4cJ0MT3Fs48pQxrZeyZHcn+klFherytILVfE4aYrneg==} engines: {node: '>=14.18.0', npm: '>=8.0.0'} peerDependencies: @@ -3854,7 +3854,7 @@ packages: '@rollup/pluginutils': 5.0.2(rollup@3.26.3) debug: 4.3.4(supports-color@9.4.0) es-module-lexer: 1.3.0 - esbuild: 0.18.15 + esbuild: 0.18.17 joycon: 3.1.1 jsonc-parser: 3.2.0 rollup: 3.26.3 @@ -3878,7 +3878,7 @@ packages: /rxjs@7.8.1: resolution: {integrity: sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==} dependencies: - tslib: 2.6.0 + tslib: 2.6.1 dev: true /safe-array-concat@1.0.0: @@ -4003,8 +4003,8 @@ packages: engines: {node: '>=14'} dev: true - /simple-git-hooks@2.8.1: - resolution: {integrity: sha512-DYpcVR1AGtSfFUNzlBdHrQGPsOhuuEJ/FkmPOOlFysP60AHd3nsEpkGq/QEOdtUyT1Qhk7w9oLmFoMG+75BDog==} + /simple-git-hooks@2.9.0: + resolution: {integrity: sha512-waSQ5paUQtyGC0ZxlHmcMmD9I1rRXauikBwX31bX58l5vTOhCEcBC5Bi+ZDkPXTjDnZAF8TbCqKBY+9+sVPScw==} hasBin: true requiresBuild: true dev: true @@ -4324,8 +4324,8 @@ packages: regexparam: 1.3.0 dev: true - /tslib@2.6.0: - resolution: {integrity: sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA==} + /tslib@2.6.1: + resolution: {integrity: sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig==} dev: true /type-detect@4.0.8: @@ -4449,7 +4449,7 @@ packages: engines: {node: '>= 0.8'} dev: true - /vite-node@0.33.0(@types/node@20.4.3)(supports-color@9.4.0): + /vite-node@0.33.0(@types/node@20.4.5)(supports-color@9.4.0): resolution: {integrity: sha512-19FpHYbwWWxDr73ruNahC+vtEdza52kA90Qb3La98yZ0xULqV8A5JLNPUff0f5zID4984tW7l3DH2przTJUZSw==} engines: {node: '>=v14.18.0'} hasBin: true @@ -4459,7 +4459,7 @@ packages: mlly: 1.4.0 pathe: 1.1.1 picocolors: 1.0.0 - vite: 4.4.7(@types/node@20.4.3) + vite: 4.4.7(@types/node@20.4.5) transitivePeerDependencies: - '@types/node' - less @@ -4471,7 +4471,7 @@ packages: - terser dev: true - /vite@4.4.7(@types/node@20.4.3): + /vite@4.4.7(@types/node@20.4.5): resolution: {integrity: sha512-6pYf9QJ1mHylfVh39HpuSfMPojPSKVxZvnclX1K1FyZ1PXDOcLBibdq5t1qxJSnL63ca8Wf4zts6mD8u8oc9Fw==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true @@ -4499,8 +4499,8 @@ packages: terser: optional: true dependencies: - '@types/node': 20.4.3 - esbuild: 0.18.15 + '@types/node': 20.4.5 + esbuild: 0.18.17 postcss: 8.4.27 rollup: 3.26.3 optionalDependencies: @@ -4539,7 +4539,7 @@ packages: dependencies: '@types/chai': 4.3.5 '@types/chai-subset': 1.3.3 - '@types/node': 20.4.3 + '@types/node': 20.4.5 '@vitest/expect': 0.33.0 '@vitest/runner': 0.33.0 '@vitest/snapshot': 0.33.0 @@ -4558,8 +4558,8 @@ packages: strip-literal: 1.0.1 tinybench: 2.5.0 tinypool: 0.6.0 - vite: 4.4.7(@types/node@20.4.3) - vite-node: 0.33.0(@types/node@20.4.3)(supports-color@9.4.0) + vite: 4.4.7(@types/node@20.4.5) + vite-node: 0.33.0(@types/node@20.4.5)(supports-color@9.4.0) why-is-node-running: 2.2.2 transitivePeerDependencies: - less diff --git a/src/node/plugins/localSearchPlugin.ts b/src/node/plugins/localSearchPlugin.ts index eca0f203..5391f665 100644 --- a/src/node/plugins/localSearchPlugin.ts +++ b/src/node/plugins/localSearchPlugin.ts @@ -169,9 +169,8 @@ export async function localSearchPlugin( config: () => ({ optimizeDeps: { include: [ - // FIXME! - // 'vitepress > @vueuse/integrations/useFocusTrap', - // 'vitepress > mark.js/src/vanilla.js', + 'vitepress > @vueuse/integrations/useFocusTrap', + 'vitepress > mark.js/src/vanilla.js', 'vitepress > minisearch' ] } From 74d9ba27b53c6fd09b91b58bba9c1f138a6ee6f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=BD=E5=AE=81?= Date: Wed, 26 Jul 2023 16:45:16 +0800 Subject: [PATCH 003/516] fix(build): `createContentLoader` generates invalid url when `srcDir` is set (#2578) BREAKING CHANGE: `createContentLoader` will now resolve globs relative to `srcDir` instead of `root` --- docs/guide/data-loading.md | 2 +- src/node/contentLoader.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide/data-loading.md b/docs/guide/data-loading.md index a2d1405c..d23e25d6 100644 --- a/docs/guide/data-loading.md +++ b/docs/guide/data-loading.md @@ -91,7 +91,7 @@ import { createContentLoader } from 'vitepress' export default createContentLoader('posts/*.md', /* options */) ``` -The helper takes a glob pattern relative to [project root](./routing#project-root), and returns a `{ watch, load }` data loader object that can be used as the default export in a data loader file. It also implements caching based on file modified timestamps to improve dev performance. +The helper takes a glob pattern relative to the [source directory](./routing#source-directory), and returns a `{ watch, load }` data loader object that can be used as the default export in a data loader file. It also implements caching based on file modified timestamps to improve dev performance. Note the loader only works with Markdown files - matched non-Markdown files will be skipped. diff --git a/src/node/contentLoader.ts b/src/node/contentLoader.ts index 6c624293..048fc216 100644 --- a/src/node/contentLoader.ts +++ b/src/node/contentLoader.ts @@ -115,7 +115,7 @@ export function createContentLoader( }) const url = '/' + - normalizePath(path.relative(config.root, file)).replace( + normalizePath(path.relative(config.srcDir, file)).replace( /\.md$/, config.cleanUrls ? '' : '.html' ) From 51f28bfac96bbb14ea0175c796e0d18fff3b2cc5 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Wed, 26 Jul 2023 16:19:36 +0530 Subject: [PATCH 004/516] fix(theme): fix feature component always generating anchor tags --- src/client/theme-default/components/VPLink.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/theme-default/components/VPLink.vue b/src/client/theme-default/components/VPLink.vue index daf85508..426a2544 100644 --- a/src/client/theme-default/components/VPLink.vue +++ b/src/client/theme-default/components/VPLink.vue @@ -11,7 +11,7 @@ const props = defineProps<{ rel?: string }>() -const tag = computed(() => props.tag ?? props.href ? 'a' : 'span') +const tag = computed(() => props.tag ?? (props.href ? 'a' : 'span')) const isExternal = computed(() => props.href && EXTERNAL_URL_RE.test(props.href)) From b61f36d85326912ca67f552ecbe89aa4ca0b1919 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Thu, 27 Jul 2023 14:58:08 +0530 Subject: [PATCH 005/516] fix(build): use vue dev build when DEBUG is truthy (#2689) --- src/node/alias.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/node/alias.ts b/src/node/alias.ts index aeefcbe1..c485a33b 100644 --- a/src/node/alias.ts +++ b/src/node/alias.ts @@ -18,12 +18,15 @@ export const DEFAULT_THEME_PATH = join(DIST_CLIENT_PATH, 'theme-default') export const SITE_DATA_ID = '@siteData' export const SITE_DATA_REQUEST_PATH = '/' + SITE_DATA_ID -const vueRuntimePath = 'vue/dist/vue.runtime.esm-bundler.js' - export function resolveAliases( { root, themeDir }: SiteConfig, ssr: boolean ): AliasOptions { + const vueRuntimePath = + process.env.DEBUG || process.env.NODE_ENV !== 'production' + ? 'vue/dist/vue.runtime.esm-browser.js' + : 'vue/dist/vue.runtime.esm-browser.prod.js' + const paths: Record = { '@theme': themeDir, [SITE_DATA_ID]: SITE_DATA_REQUEST_PATH From 5563695b1599165fa85ea69f15334e27ab6955bf Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Thu, 27 Jul 2023 23:52:17 +0530 Subject: [PATCH 006/516] feat: sitemap generation (#2691) --- docs/.vitepress/config.ts | 8 +++++ docs/guide/sitemap-generation.md | 53 +++++++++++++++++++++++++++ package.json | 1 + pnpm-lock.yaml | 32 +++++++++++++++++ src/node/build/build.ts | 19 +++------- src/node/build/bundle.ts | 31 +++++----------- src/node/build/generateSitemap.ts | 60 +++++++++++++++++++++++++++++++ src/node/config.ts | 3 +- src/node/siteConfig.ts | 33 +++++++++++------ src/node/utils/getGitTimestamp.ts | 9 ++++- src/node/utils/task.ts | 18 ++++++++++ 11 files changed, 218 insertions(+), 49 deletions(-) create mode 100644 docs/guide/sitemap-generation.md create mode 100644 src/node/build/generateSitemap.ts create mode 100644 src/node/utils/task.ts diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 265e8f0c..7033ca61 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -12,6 +12,10 @@ export default defineConfig({ lastUpdated: true, cleanUrls: true, + sitemap: { + hostname: 'https://vitepress.dev' + }, + head: [ ['meta', { name: 'theme-color', content: '#3c8772' }], [ @@ -131,6 +135,10 @@ function sidebarGuide() { { text: 'MPA Mode', link: '/guide/mpa-mode' + }, + { + text: 'Sitemap Generation', + link: '/guide/sitemap-generation' } ] }, diff --git a/docs/guide/sitemap-generation.md b/docs/guide/sitemap-generation.md new file mode 100644 index 00000000..7d891428 --- /dev/null +++ b/docs/guide/sitemap-generation.md @@ -0,0 +1,53 @@ +# Sitemap Generation + +VitePress comes with out-of-the-box support for generating a `sitemap.xml` file for your site. To enable it, add the following to your `.vitepress/config.js`: + +```ts +import { defineConfig } from 'vitepress' + +export default defineConfig({ + sitemap: { + hostname: 'https://example.com' + } +}) +``` + +To have `` tags in your `sitemap.xml`, you can enable the [`lastUpdated`](../reference/default-theme-last-updated) option. + +## Options + +Sitemap support is powered by the [`sitemap`](https://www.npmjs.com/package/sitemap) module. You can pass any options supported by it to the `sitemap` option in your config file. These will be passed directly to the `SitemapStream` constructor. Refer to the [`sitemap` documentation](https://www.npmjs.com/package/sitemap#options-you-can-pass) for more details. Example: + +```ts +import { defineConfig } from 'vitepress' + +export default defineConfig({ + sitemap: { + hostname: 'https://example.com', + lastmodDateOnly: false + } +}) +``` + +## `transformItems` Hook + +You can use the `sitemap.transformItems` hook to modify the sitemap items before they are written to the `sitemap.xml` file. This hook is called with an array of sitemap items and expects an array of sitemap items to be returned. Example: + +```ts +import { defineConfig } from 'vitepress' + +export default defineConfig({ + sitemap: { + hostname: 'https://example.com', + transformItems: (items) => { + // add new items or modify/filter existing items + items.push({ + url: '/extra-page', + changefreq: 'monthly', + priority: 0.8 + }) + return items + } + } +}) +``` diff --git a/package.json b/package.json index 0c14c675..5416945c 100644 --- a/package.json +++ b/package.json @@ -176,6 +176,7 @@ "shiki-processor": "^0.1.3", "simple-git-hooks": "^2.9.0", "sirv": "^2.0.3", + "sitemap": "^7.1.1", "supports-color": "^9.4.0", "typescript": "^5.1.6", "vitest": "^0.33.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2d85eb2f..4d1f377d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -258,6 +258,9 @@ importers: sirv: specifier: ^2.0.3 version: 2.0.3 + sitemap: + specifier: ^7.1.1 + version: 7.1.1 supports-color: specifier: ^9.4.0 version: 9.4.0 @@ -1101,6 +1104,10 @@ packages: resolution: {integrity: sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==} dev: true + /@types/node@17.0.45: + resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==} + dev: true + /@types/node@20.4.5: resolution: {integrity: sha512-rt40Nk13II9JwQBdeYqmbn2Q6IVTA5uPhvSO+JVqdXw/6/4glI6oR9ezty/A9Hg5u7JH4OmYmuQ+XvjKm0Datg==} @@ -1127,6 +1134,12 @@ packages: resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} dev: true + /@types/sax@1.2.4: + resolution: {integrity: sha512-pSAff4IAxJjfAXUG6tFkO7dsSbTmf8CtUpfhhZ5VhkRpC4628tJhh3+V6H1E+/Gs9piSzYKT5yzHO5M4GG9jkw==} + dependencies: + '@types/node': 20.4.5 + dev: true + /@types/send@0.17.1: resolution: {integrity: sha512-Cwo8LE/0rnvX7kIIa3QHCkcuF21c05Ayb0ZfxPiv0W8VRiZiNW/WuRupHKpqqGVGf7SUA44QSOUKaEd9lIrd/Q==} dependencies: @@ -1513,6 +1526,10 @@ packages: picomatch: 2.3.1 dev: true + /arg@5.0.2: + resolution: {integrity: sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==} + dev: true + /argparse@1.0.10: resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} dependencies: @@ -3907,6 +3924,10 @@ packages: is-regex: 1.1.4 dev: true + /sax@1.2.4: + resolution: {integrity: sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==} + dev: true + /search-insights@2.7.0: resolution: {integrity: sha512-GLbVaGgzYEKMvuJbHRhLi1qoBFnjXZGZ6l4LxOYPCp4lI2jDRB3jPU9/XNhMwv6kvnA9slTreq6pvK+b3o3aqg==} engines: {node: '>=8.16.0'} @@ -4022,6 +4043,17 @@ packages: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} dev: true + /sitemap@7.1.1: + resolution: {integrity: sha512-mK3aFtjz4VdJN0igpIJrinf3EO8U8mxOPsTBzSsy06UtjZQJ3YY3o3Xa7zSc5nMqcMrRwlChHZ18Kxg0caiPBg==} + engines: {node: '>=12.0.0', npm: '>=5.6.0'} + hasBin: true + dependencies: + '@types/node': 17.0.45 + '@types/sax': 1.2.4 + arg: 5.0.2 + sax: 1.2.4 + dev: true + /slash@4.0.0: resolution: {integrity: sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==} engines: {node: '>=12'} diff --git a/src/node/build/build.ts b/src/node/build/build.ts index 1626452e..255995b6 100644 --- a/src/node/build/build.ts +++ b/src/node/build/build.ts @@ -1,7 +1,6 @@ import { createHash } from 'crypto' import fs from 'fs-extra' import { createRequire } from 'module' -import ora from 'ora' import path from 'path' import { packageDirectorySync } from 'pkg-dir' import { rimraf } from 'rimraf' @@ -11,7 +10,9 @@ import type { BuildOptions } from 'vite' import { resolveConfig, type SiteConfig } from '../config' import { slash, type HeadConfig } from '../shared' import { deserializeFunctions, serializeFunctions } from '../utils/fnSerialize' -import { bundle, failMark, okMark } from './bundle' +import { task } from '../utils/task' +import { bundle } from './bundle' +import { generateSitemap } from './generateSitemap' import { renderPage } from './render' export async function build( @@ -43,10 +44,7 @@ export async function build( const entryPath = path.join(siteConfig.tempDir, 'app.js') const { render } = await import(pathToFileURL(entryPath).toString()) - const spinner = ora({ discardStdin: false }) - spinner.start('rendering pages...') - - try { + await task('rendering pages', async () => { const appChunk = clientResult && (clientResult.output.find( @@ -118,14 +116,6 @@ export async function build( ) ) ) - } catch (e) { - spinner.stopAndPersist({ - symbol: failMark - }) - throw e - } - spinner.stopAndPersist({ - symbol: okMark }) // emit page hash map for the case where a user session is open @@ -139,6 +129,7 @@ export async function build( if (!process.env.DEBUG) await rimraf(siteConfig.tempDir) } + await generateSitemap(siteConfig) await siteConfig.buildEnd?.(siteConfig) siteConfig.logger.info( diff --git a/src/node/build/bundle.ts b/src/node/build/bundle.ts index d9c3d474..2d8e8dfd 100644 --- a/src/node/build/bundle.ts +++ b/src/node/build/bundle.ts @@ -1,22 +1,19 @@ -import ora from 'ora' -import path from 'path' import fs from 'fs-extra' +import path from 'path' +import type { GetModuleInfo, RollupOutput } from 'rollup' +import { fileURLToPath } from 'url' import { build, + normalizePath, type BuildOptions, type UserConfig as ViteUserConfig } from 'vite' -import type { GetModuleInfo, RollupOutput } from 'rollup' -import type { SiteConfig } from '../config' import { APP_PATH } from '../alias' +import type { SiteConfig } from '../config' import { createVitePressPlugin } from '../plugin' import { sanitizeFileName, slash } from '../shared' +import { task } from '../utils/task' import { buildMPAClient } from './buildMPAClient' -import { fileURLToPath } from 'url' -import { normalizePath } from 'vite' - -export const okMark = '\x1b[32m✓\x1b[0m' -export const failMark = '\x1b[31m✖\x1b[0m' // A list of default theme components that should only be loaded on demand. const lazyDefaultThemeComponentsRE = @@ -142,24 +139,14 @@ export async function bundle( } }) - let clientResult: RollupOutput | null - let serverResult: RollupOutput + let clientResult!: RollupOutput | null + let serverResult!: RollupOutput - const spinner = ora({ discardStdin: false }) - spinner.start('building client + server bundles...') - try { + await task('building client + server bundles', async () => { clientResult = config.mpa ? null : ((await build(await resolveViteConfig(false))) as RollupOutput) serverResult = (await build(await resolveViteConfig(true))) as RollupOutput - } catch (e) { - spinner.stopAndPersist({ - symbol: failMark - }) - throw e - } - spinner.stopAndPersist({ - symbol: okMark }) if (config.mpa) { diff --git a/src/node/build/generateSitemap.ts b/src/node/build/generateSitemap.ts new file mode 100644 index 00000000..e04bd729 --- /dev/null +++ b/src/node/build/generateSitemap.ts @@ -0,0 +1,60 @@ +import fs from 'fs-extra' +import path from 'path' +import { + SitemapStream, + type EnumChangefreq, + type Img, + type LinkItem, + type NewsItem +} from 'sitemap' +import type { SiteConfig } from '../config' +import { getGitTimestamp } from '../utils/getGitTimestamp' +import { task } from '../utils/task' + +export async function generateSitemap(siteConfig: SiteConfig) { + if (!siteConfig.sitemap?.hostname) return + + await task('generating sitemap', async () => { + let items: SitemapItem[] = await Promise.all( + siteConfig.pages.map(async (page) => { + // + let url = siteConfig.rewrites.map[page] || page + url = url.replace(/(^|\/)?index.md$/, '$1') + url = url.replace(/\.md$/, siteConfig.cleanUrls ? '' : '.html') + + const lastmod = siteConfig.lastUpdated && (await getGitTimestamp(page)) + return lastmod ? { url, lastmod } : { url } + }) + ) + items = items.sort((a, b) => a.url.localeCompare(b.url)) + items = (await siteConfig.sitemap?.transformItems?.(items)) || items + + const sitemapStream = new SitemapStream(siteConfig.sitemap) + const sitemapPath = path.join(siteConfig.outDir, 'sitemap.xml') + const writeStream = fs.createWriteStream(sitemapPath) + + sitemapStream.pipe(writeStream) + items.forEach((item) => sitemapStream.write(item)) + sitemapStream.end() + }) +} + +// ============================== Patched Types =============================== + +export interface SitemapItem { + lastmod?: string | number | Date + changefreq?: `${EnumChangefreq}` + fullPrecisionPriority?: boolean + priority?: number + news?: NewsItem + expires?: string + androidLink?: string + ampLink?: string + url: string + video?: any + img?: string | Img | (string | Img)[] + links?: LinkItem[] + lastmodfile?: string | Buffer | URL + lastmodISO?: string + lastmodrealtime?: boolean +} diff --git a/src/node/config.ts b/src/node/config.ts index 6144d876..b39250cd 100644 --- a/src/node/config.ts +++ b/src/node/config.ts @@ -127,7 +127,8 @@ export async function resolveConfig( transformHtml: userConfig.transformHtml, transformPageData: userConfig.transformPageData, rewrites, - userConfig + userConfig, + sitemap: userConfig.sitemap } // to be shared with content loaders diff --git a/src/node/siteConfig.ts b/src/node/siteConfig.ts index 6a1cea00..c2f58d76 100644 --- a/src/node/siteConfig.ts +++ b/src/node/siteConfig.ts @@ -1,15 +1,17 @@ -import { - type Awaitable, - type HeadConfig, - type LocaleConfig, - type LocaleSpecificConfig, - type PageData, - type SiteData, - type SSGContext -} from './shared' -import type { MarkdownOptions } from './markdown' import type { Options as VuePluginOptions } from '@vitejs/plugin-vue' -import { type Logger, type UserConfig as ViteConfig } from 'vite' +import type { SitemapStreamOptions } from 'sitemap' +import type { Logger, UserConfig as ViteConfig } from 'vite' +import type { SitemapItem } from './build/generateSitemap' +import type { MarkdownOptions } from './markdown' +import type { + Awaitable, + HeadConfig, + LocaleConfig, + LocaleSpecificConfig, + PageData, + SSGContext, + SiteData +} from './shared' export type RawConfigExports = | Awaitable> @@ -138,6 +140,14 @@ export interface UserConfig */ rewrites?: Record + /** + * @experimental + */ + sitemap?: SitemapStreamOptions & { + hostname: string + transformItems?: (items: SitemapItem[]) => Awaitable + } + /** * Build end hook: called when SSG finish. * @param siteConfig The resolved configuration. @@ -192,6 +202,7 @@ export interface SiteConfig | 'transformHead' | 'transformHtml' | 'transformPageData' + | 'sitemap' > { root: string srcDir: string diff --git a/src/node/utils/getGitTimestamp.ts b/src/node/utils/getGitTimestamp.ts index 5404c512..51d01df7 100644 --- a/src/node/utils/getGitTimestamp.ts +++ b/src/node/utils/getGitTimestamp.ts @@ -1,7 +1,12 @@ import { spawn } from 'cross-spawn' import { basename, dirname } from 'path' +const cache = new Map() + export function getGitTimestamp(file: string) { + const cached = cache.get(file) + if (cached) return cached + return new Promise((resolve, reject) => { const cwd = dirname(file) const fileName = basename(file) @@ -11,7 +16,9 @@ export function getGitTimestamp(file: string) { let output = '' child.stdout.on('data', (d) => (output += String(d))) child.on('close', () => { - resolve(+new Date(output)) + const timestamp = +new Date(output) + cache.set(file, timestamp) + resolve(timestamp) }) child.on('error', reject) }) diff --git a/src/node/utils/task.ts b/src/node/utils/task.ts new file mode 100644 index 00000000..1d8a3322 --- /dev/null +++ b/src/node/utils/task.ts @@ -0,0 +1,18 @@ +import ora from 'ora' + +export const okMark = '\x1b[32m✓\x1b[0m' +export const failMark = '\x1b[31m✖\x1b[0m' + +export async function task(taskName: string, task: () => Promise) { + const spinner = ora({ discardStdin: false }) + spinner.start(taskName + '...') + + try { + await task() + } catch (e) { + spinner.stopAndPersist({ symbol: failMark }) + throw e + } + + spinner.stopAndPersist({ symbol: okMark }) +} From b39b4912af9664d14f5f7c658e64b96de3865f04 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Fri, 28 Jul 2023 21:32:31 +0530 Subject: [PATCH 007/516] fix(theme): code group tab divider not showing full-width (#2701) --- .../theme-default/styles/components/vp-code-group.css | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/client/theme-default/styles/components/vp-code-group.css b/src/client/theme-default/styles/components/vp-code-group.css index 79d02fec..aa0675e8 100644 --- a/src/client/theme-default/styles/components/vp-code-group.css +++ b/src/client/theme-default/styles/components/vp-code-group.css @@ -11,16 +11,7 @@ background-color: var(--vp-code-tab-bg); overflow-x: auto; overflow-y: hidden; -} - -.vp-code-group .tabs::after { - position: absolute; - right: 0; - bottom: 0; - left: 0; - height: 1px; - background-color: var(--vp-code-tab-divider); - content: ''; + box-shadow: inset 0 -1px var(--vp-code-tab-divider); } @media (min-width: 640px) { From 68f25f5a9cca1d059831184ad8876bb40326d9b6 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Fri, 28 Jul 2023 23:25:51 +0530 Subject: [PATCH 008/516] fix(build): duplicate description tags with transformHead (#2702) --- src/node/build/render.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/node/build/render.ts b/src/node/build/render.ts index a3079903..8a283b90 100644 --- a/src/node/build/render.ts +++ b/src/node/build/render.ts @@ -158,7 +158,11 @@ export async function renderPage( : '' } ${title} - + ${ + isDescriptionOverridden(head) + ? '' + : `` + } ${stylesheetLink} ${metadataScript.inHead ? metadataScript.html : ''} ${ @@ -258,6 +262,12 @@ function filterOutHeadDescription(head: HeadConfig[] = []) { }) } +function isDescriptionOverridden(head: HeadConfig[] = []) { + return head.some(([type, attrs]) => { + return type === 'meta' && attrs?.name === 'description' + }) +} + function isMetaViewportOverridden(head: HeadConfig[] = []) { return head.some(([type, attrs]) => { return type === 'meta' && attrs?.name === 'viewport' From 13f94a6663d5b4472ce380ee1c27e6124da8fec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=BD=E5=AE=81?= Date: Sat, 29 Jul 2023 18:26:47 +0800 Subject: [PATCH 009/516] feat(build): custom excerpt for `createContentLoader` (#2698) Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> --- docs/guide/data-loading.md | 54 ++++++++++++++++++++++++--- docs/guide/deploy.md | 2 +- docs/guide/extending-default-theme.md | 4 +- docs/guide/ssr-compat.md | 2 +- docs/reference/runtime-api.md | 2 +- src/node/contentLoader.ts | 42 +++++++++++++++++---- 6 files changed, 87 insertions(+), 19 deletions(-) diff --git a/docs/guide/data-loading.md b/docs/guide/data-loading.md index d23e25d6..6d54b2ca 100644 --- a/docs/guide/data-loading.md +++ b/docs/guide/data-loading.md @@ -23,7 +23,7 @@ The loader module is evaluated only in Node.js, so you can import Node APIs and You can then import data from this file in `.md` pages and `.vue` components using the `data` named export: -```html +```vue @@ -70,7 +70,7 @@ export default { // watchedFiles will be an array of absolute paths of the matched files. // generate an array of blog post metadata that can be used to render // a list in the theme layout - return watchedFiles.map(file => { + return watchedFiles.map((file) => { return parse(fs.readFileSync(file, 'utf-8'), { columns: true, skip_empty_lines: true @@ -147,9 +147,9 @@ export default createContentLoader('posts/*.md', { // the final result is what will be shipped to the client. return rawData.sort((a, b) => { return +new Date(b.frontmatter.date) - +new Date(a.frontmatter.date) - }).map(page => { - page.src // raw markdown source - page.html // rendered full page HTML + }).map((page) => { + page.src // raw markdown source + page.html // rendered full page HTML page.excerpt // rendered excerpt HTML (content above first `---`) return {/* ... */} }) @@ -159,7 +159,7 @@ export default createContentLoader('posts/*.md', { Check out how it is used in the [Vue.js blog](https://github.com/vuejs/blog/blob/main/.vitepress/theme/posts.data.ts). -The `createContentLoader` API can also be used inside [build hooks](/reference/site-config#build-hooks): +The `createContentLoader` API can also be used inside [build hooks](../reference/site-config#build-hooks): ```js // .vitepress/config.js @@ -171,6 +171,48 @@ export default { } ``` +**Types** + +```ts +interface ContentOptions { + /** + * Include src? + * @default false + */ + includeSrc?: boolean + + /** + * Render src to HTML and include in data? + * @default false + */ + render?: boolean + + /** + * If `boolean`, whether to parse and include excerpt? (rendered as HTML) + * + * If `function`, control how the excerpt is extracted from the content. + * + * If `string`, define a custom separator to be used for extracting the + * excerpt. Default separator is `---` if `excerpt` is `true`. + * + * @see https://github.com/jonschlinkert/gray-matter#optionsexcerpt + * @see https://github.com/jonschlinkert/gray-matter#optionsexcerpt_separator + * + * @default false + */ + excerpt?: + | boolean + | ((file: { data: { [key: string]: any }; content: string; excerpt?: string }, options?: any) => void) + | string + + /** + * Transform the data. Note the data will be inlined as JSON in the client + * bundle if imported from components or markdown files. + */ + transform?: (data: ContentData[]) => T | Promise +} +``` + ## Typed Data Loaders When using TypeScript, you can type your loader and `data` export like so: diff --git a/docs/guide/deploy.md b/docs/guide/deploy.md index 7ebbc314..679d9ff9 100644 --- a/docs/guide/deploy.md +++ b/docs/guide/deploy.md @@ -73,7 +73,7 @@ Cache-Control: max-age=31536000,immutable cache-control: immutable ``` -Note: the `_headers` file should be placed in the [public directory](/guide/asset-handling#the-public-directory) - in our case, `docs/public/_headers` - so that it is copied verbatim to the output directory. +Note: the `_headers` file should be placed in the [public directory](./asset-handling#the-public-directory) - in our case, `docs/public/_headers` - so that it is copied verbatim to the output directory. [Netlify custom headers documentation](https://docs.netlify.com/routing/headers/) diff --git a/docs/guide/extending-default-theme.md b/docs/guide/extending-default-theme.md index a0ccfd9e..332fa971 100644 --- a/docs/guide/extending-default-theme.md +++ b/docs/guide/extending-default-theme.md @@ -59,10 +59,10 @@ export default DefaultTheme ``` ::: warning -If you are using optional components like the [Team Page](/reference/default-theme-team-page) components, make sure to also import them from `vitepress/theme-without-fonts`! +If you are using optional components like the [Team Page](../reference/default-theme-team-page) components, make sure to also import them from `vitepress/theme-without-fonts`! ::: -If your font is a local file referenced via `@font-face`, it will be processed as an asset and included under `.vitepress/dist/assets` with hashed filename. To preload this file, use the [transformHead](/reference/site-config#transformhead) build hook: +If your font is a local file referenced via `@font-face`, it will be processed as an asset and included under `.vitepress/dist/assets` with hashed filename. To preload this file, use the [transformHead](../reference/site-config#transformhead) build hook: ```js // .vitepress/config.js diff --git a/docs/guide/ssr-compat.md b/docs/guide/ssr-compat.md index 11c6a081..82eb58e5 100644 --- a/docs/guide/ssr-compat.md +++ b/docs/guide/ssr-compat.md @@ -48,7 +48,7 @@ if (!import.meta.env.SSR) { } ``` -Since [`Theme.enhanceApp`](/guide/custom-theme#theme-interface) can be async, you can conditionally import and register Vue plugins that access browser APIs on import: +Since [`Theme.enhanceApp`](./custom-theme#theme-interface) can be async, you can conditionally import and register Vue plugins that access browser APIs on import: ```js // .vitepress/theme/index.js diff --git a/docs/reference/runtime-api.md b/docs/reference/runtime-api.md index e4839d0c..03bb6160 100644 --- a/docs/reference/runtime-api.md +++ b/docs/reference/runtime-api.md @@ -141,7 +141,7 @@ If you are using or demoing components that are not SSR-friendly (for example, c ``` -- Related: [SSR Compatibility](/guide/ssr-compat) +- Related: [SSR Compatibility](../guide/ssr-compat) ## `$frontmatter` diff --git a/src/node/contentLoader.ts b/src/node/contentLoader.ts index 048fc216..98c5585d 100644 --- a/src/node/contentLoader.ts +++ b/src/node/contentLoader.ts @@ -9,19 +9,41 @@ import { createMarkdownRenderer, type MarkdownRenderer } from './markdown' export interface ContentOptions { /** * Include src? - * default: false + * @default false */ includeSrc?: boolean + /** * Render src to HTML and include in data? - * default: false + * @default false */ render?: boolean + /** - * Whether to parse and include excerpt (rendered as HTML) - * default: false + * If `boolean`, whether to parse and include excerpt? (rendered as HTML) + * + * If `function`, control how the excerpt is extracted from the content. + * + * If `string`, define a custom separator to be used for extracting the + * excerpt. Default separator is `---` if `excerpt` is `true`. + * + * @see https://github.com/jonschlinkert/gray-matter#optionsexcerpt + * @see https://github.com/jonschlinkert/gray-matter#optionsexcerpt_separator + * + * @default false */ - excerpt?: boolean + excerpt?: + | boolean + | (( + file: { + data: { [key: string]: any } + content: string + excerpt?: string + }, + options?: any + ) => void) + | string + /** * Transform the data. Note the data will be inlined as JSON in the client * bundle if imported from components or markdown files. @@ -110,9 +132,13 @@ export function createContentLoader( raw.push(cached.data) } else { const src = fs.readFileSync(file, 'utf-8') - const { data: frontmatter, excerpt } = matter(src, { - excerpt: true - }) + const { data: frontmatter, excerpt } = matter( + src, + // @ts-expect-error gray-matter types are wrong + typeof renderExcerpt === 'string' + ? { excerpt_separator: renderExcerpt } + : { excerpt: renderExcerpt } + ) const url = '/' + normalizePath(path.relative(config.srcDir, file)).replace( From 2ae90a234338ea074b536e5583d81fd565d8e3f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=BD=E5=AE=81?= Date: Sat, 29 Jul 2023 18:33:23 +0800 Subject: [PATCH 010/516] feat(theme): support custom page class (#2696) Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> --- docs/reference/frontmatter-config.md | 42 ++++++++++++++++++++-------- src/client/theme-default/Layout.vue | 2 +- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/docs/reference/frontmatter-config.md b/docs/reference/frontmatter-config.md index 4bbf65d5..10297687 100644 --- a/docs/reference/frontmatter-config.md +++ b/docs/reference/frontmatter-config.md @@ -86,7 +86,7 @@ type HeadConfig = The following frontmatter options are only applicable when using the default theme. -### layout +### layout - Type: `doc | home | page` - Default: `doc` @@ -103,15 +103,15 @@ layout: doc --- ``` -### hero +### hero Defines contents of home hero section when `layout` is set to `home`. More details in [Default Theme: Home Page](./default-theme-home-page). -### features +### features Defines items to display in features section when `layout` is set to `home`. More details in [Default Theme: Home Page](./default-theme-home-page). -### navbar +### navbar - Type: `boolean` - Default: `true` @@ -124,7 +124,7 @@ navbar: false --- ``` -### sidebar +### sidebar - Type: `boolean` - Default: `true` @@ -137,7 +137,7 @@ sidebar: false --- ``` -### aside +### aside - Type: `boolean | 'left'` - Default: `true` @@ -154,14 +154,14 @@ aside: false --- ``` -### outline +### outline - Type: `number | [number, number] | 'deep' | false` - Default: `2` The levels of header in the outline to display for the page. It's same as [config.themeConfig.outline](./default-theme-config#outline), and it overrides the theme config. -### lastUpdated +### lastUpdated - Type: `boolean` - Default: `true` @@ -174,7 +174,7 @@ lastUpdated: false --- ``` -### editLink +### editLink - Type: `boolean` - Default: `true` @@ -187,15 +187,35 @@ editLink: false --- ``` -### footer +### footer - Type: `boolean` - Default: `true` -Whether to display [footer](./default-theme-footer). +Whether to display [footer](./default-theme-footer). ```yaml --- footer: false --- ``` + +### pageClass + +- Type: `string` + +Add extra class name to a specific page. + +```yaml +--- +pageClass: custom-page-class +--- +``` + +Then you can customize styles of this specific page in `.vitepress/theme/custom.css` file: + +```css +.custom-page-class { +  /* page-specific styles */ +} +``` diff --git a/src/client/theme-default/Layout.vue b/src/client/theme-default/Layout.vue index 7afba576..80f298b5 100644 --- a/src/client/theme-default/Layout.vue +++ b/src/client/theme-default/Layout.vue @@ -34,7 +34,7 @@ provide('hero-image-slot-exists', heroImageSlotExists)