From eac03f26e2d3ab47158ac2528210e95460f6c302 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 25 Mar 2023 19:11:42 +0100 Subject: [PATCH 1/6] fix(theme): remove label background of code-group tabs (#2136) --- src/client/theme-default/styles/components/vp-code-group.css | 1 - 1 file changed, 1 deletion(-) 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 84ed9b8b..c0a9c092 100644 --- a/src/client/theme-default/styles/components/vp-code-group.css +++ b/src/client/theme-default/styles/components/vp-code-group.css @@ -46,7 +46,6 @@ font-size: 14px; font-weight: 500; color: var(--vp-code-tab-text-color); - background-color: var(--vp-code-tab-bg); white-space: nowrap; cursor: pointer; transition: color 0.25s; From 3235c23313d81f8f95b91779a48db839c02aa952 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 25 Mar 2023 20:54:18 +0100 Subject: [PATCH 2/6] feat: more flexible `ignoreDeadLinks` (#2135) --- docs/reference/site-config.md | 25 ++++++++++++++++++++++-- package.json | 2 +- src/node/config.ts | 5 ++++- src/node/markdownToVue.ts | 36 ++++++++++++++++++++++++++--------- src/node/plugin.ts | 3 +-- 5 files changed, 56 insertions(+), 15 deletions(-) diff --git a/docs/reference/site-config.md b/docs/reference/site-config.md index 59f176a2..7c3fa190 100644 --- a/docs/reference/site-config.md +++ b/docs/reference/site-config.md @@ -282,10 +282,12 @@ export default { ### ignoreDeadLinks -- Type: `boolean | 'localhostLinks'` +- Type: `boolean | 'localhostLinks' | (string | RegExp | ((link: string) => boolean))[]` - Default: `false` -When set to `true`, VitePress will not fail builds due to dead links. When set to `'localhostLinks'`, the build will fail on dead links, but won't check `localhost` links. +When set to `true`, VitePress will not fail builds due to dead links. + +When set to `'localhostLinks'`, the build will fail on dead links, but won't check `localhost` links. ```ts export default { @@ -293,6 +295,25 @@ export default { } ``` +It can also be an array of extact url string, regex patterns, or custom filter functions. + +```ts +export default { + ignoreDeadLinks: [ + // ignore exact url "/playground" + '/playground', + // ignore all localhost links + /^https?:\/\/localhost/, + // ignore all links include "/repl/"" + /\/repl\//, + // custom function, ignore all links include "ignore" + (url) => { + return url.toLowerCase().includes('ignore') + } + ] +} +``` + ### mpa - Type: `boolean` diff --git a/package.json b/package.json index e5501dae..1149519a 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.0-alpha.62", "description": "Vite & Vue powered static site generator", "type": "module", - "packageManager": "pnpm@7.30.0", + "packageManager": "pnpm@7.30.3", "main": "dist/node/index.js", "types": "types/index.d.ts", "exports": { diff --git a/src/node/config.ts b/src/node/config.ts index 763aea03..63b8e9ec 100644 --- a/src/node/config.ts +++ b/src/node/config.ts @@ -85,7 +85,10 @@ export interface UserConfig * * @default false */ - ignoreDeadLinks?: boolean | 'localhostLinks' + ignoreDeadLinks?: + | boolean + | 'localhostLinks' + | (string | RegExp | ((link: string) => boolean))[] /** * Don't force `.html` on URLs. diff --git a/src/node/markdownToVue.ts b/src/node/markdownToVue.ts index 8df264bb..0d48de5a 100644 --- a/src/node/markdownToVue.ts +++ b/src/node/markdownToVue.ts @@ -125,19 +125,36 @@ export async function createMarkdownToVueRenderFn( deadLinks.push(url) } + function shouldIgnoreDeadLink(url: string) { + if (!siteConfig?.ignoreDeadLinks) { + return false + } + if (siteConfig.ignoreDeadLinks === true) { + return true + } + if (siteConfig.ignoreDeadLinks === 'localhostLinks') { + return url.replace(EXTERNAL_URL_RE, '').startsWith('//localhost') + } + + return siteConfig.ignoreDeadLinks.some((ignore) => { + if (typeof ignore === 'string') { + return url === ignore + } + if (ignore instanceof RegExp) { + return ignore.test(url) + } + if (typeof ignore === 'function') { + return ignore(url) + } + return false + }) + } + if (links) { const dir = path.dirname(file) for (let url of links) { if (/\.(?!html|md)\w+($|\?)/i.test(url)) continue - if ( - siteConfig?.ignoreDeadLinks !== 'localhostLinks' && - url.replace(EXTERNAL_URL_RE, '').startsWith('//localhost:') - ) { - recordDeadLink(url) - continue - } - url = url.replace(/[?#].*$/, '').replace(/\.(html|md)$/, '') if (url.endsWith('/')) url += `index` let resolved = decodeURIComponent( @@ -151,7 +168,8 @@ export async function createMarkdownToVueRenderFn( siteConfig?.rewrites.inv[resolved + '.md']?.slice(0, -3) || resolved if ( !pages.includes(resolved) && - !fs.existsSync(path.resolve(dir, publicDir, `${resolved}.html`)) + !fs.existsSync(path.resolve(dir, publicDir, `${resolved}.html`)) && + !shouldIgnoreDeadLink(url) ) { recordDeadLink(url) } diff --git a/src/node/plugin.ts b/src/node/plugin.ts index 0d05c021..1881d2ed 100644 --- a/src/node/plugin.ts +++ b/src/node/plugin.ts @@ -70,7 +70,6 @@ export async function createVitePressPlugin( vue: userVuePluginOptions, vite: userViteConfig, pages, - ignoreDeadLinks, lastUpdated, cleanUrls } = siteConfig @@ -195,7 +194,7 @@ export async function createVitePressPlugin( }, renderStart() { - if (hasDeadLinks && !ignoreDeadLinks) { + if (hasDeadLinks) { throw new Error(`One or more pages contain dead links.`) } }, From e5bc1e10862a765f6790f5f08aa2bd76bb258532 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sun, 26 Mar 2023 16:53:19 +0530 Subject: [PATCH 3/6] fix(theme): allow adding html as feature icons --- src/client/theme-default/components/VPFeature.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/theme-default/components/VPFeature.vue b/src/client/theme-default/components/VPFeature.vue index b9bd6af6..e1e80d9c 100644 --- a/src/client/theme-default/components/VPFeature.vue +++ b/src/client/theme-default/components/VPFeature.vue @@ -23,7 +23,7 @@ defineProps<{ :height="icon.height" :width="icon.width" /> -
{{ icon }}
+

From b16340acbd3c60fee023daadb0ec5a0292060a1e Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sun, 26 Mar 2023 17:44:37 +0530 Subject: [PATCH 4/6] release: v1.0.0-alpha.63 --- CHANGELOG.md | 15 +++++++++++++++ package.json | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a679ab97..bb8ed831 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +# [1.0.0-alpha.63](https://github.com/vuejs/vitepress/compare/v1.0.0-alpha.62...v1.0.0-alpha.63) (2023-03-26) + + +### Bug Fixes + +* **theme:** allow adding html as feature icons ([e5bc1e1](https://github.com/vuejs/vitepress/commit/e5bc1e10862a765f6790f5f08aa2bd76bb258532)) +* **theme:** remove label background of code-group tabs ([#2136](https://github.com/vuejs/vitepress/issues/2136)) ([eac03f2](https://github.com/vuejs/vitepress/commit/eac03f26e2d3ab47158ac2528210e95460f6c302)) + + +### Features + +* more flexible `ignoreDeadLinks` ([#2135](https://github.com/vuejs/vitepress/issues/2135)) ([3235c23](https://github.com/vuejs/vitepress/commit/3235c23313d81f8f95b91779a48db839c02aa952)) + + + # [1.0.0-alpha.62](https://github.com/vuejs/vitepress/compare/v1.0.0-alpha.61...v1.0.0-alpha.62) (2023-03-25) diff --git a/package.json b/package.json index 1149519a..fbd81a2e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vitepress", - "version": "1.0.0-alpha.62", + "version": "1.0.0-alpha.63", "description": "Vite & Vue powered static site generator", "type": "module", "packageManager": "pnpm@7.30.3", From ff26ff1e6683def53bfbe6cbd7656740c77f4bcc Mon Sep 17 00:00:00 2001 From: CHOYSEN Date: Tue, 28 Mar 2023 01:39:40 +0800 Subject: [PATCH 5/6] fix(theme): hide outline dropdown scrollbar when it does not overflow (#2151) --- .../theme-default/components/VPLocalNavOutlineDropdown.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/theme-default/components/VPLocalNavOutlineDropdown.vue b/src/client/theme-default/components/VPLocalNavOutlineDropdown.vue index b68890c8..7ae9c4b9 100644 --- a/src/client/theme-default/components/VPLocalNavOutlineDropdown.vue +++ b/src/client/theme-default/components/VPLocalNavOutlineDropdown.vue @@ -121,7 +121,7 @@ onContentUpdated(() => { border: 1px solid var(--vp-c-divider); border-radius: 8px; max-height: calc(var(--vp-vh, 100vh) - 86px); - overflow: scroll; + overflow: hidden auto; box-shadow: var(--vp-shadow-3); } From dae4168e1898778c6952ba24a40ec532bc11b6bb Mon Sep 17 00:00:00 2001 From: Lyric Wai <5h3ll3x@gmail.com> Date: Tue, 28 Mar 2023 02:40:26 +0900 Subject: [PATCH 6/6] docs: fix typo (#2141) --- docs/reference/default-theme-edit-link.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/default-theme-edit-link.md b/docs/reference/default-theme-edit-link.md index c52adf4e..19a22d54 100644 --- a/docs/reference/default-theme-edit-link.md +++ b/docs/reference/default-theme-edit-link.md @@ -55,6 +55,6 @@ This can be disabled per-page using the `editLink` option on frontmatter: ```yaml --- -lastUpdated: false +editLink: false --- ```