Commit c9e350253e

c9e350253eadfc88a9f74d32c709bb81c8a7904a

parent: e246f7483a

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-05-30 14:16 UTC

Revert "mememe"

This reverts commit e246f7483a452ef3f99f33e40cb28f64942904c4.

Layout: unified · split

docs/.vitepress/configs/index.ts +17 −15
@@ -10,7 +10,6 @@ import {
10 PagePropertiesMarkdownSection 10 PagePropertiesMarkdownSection
11} from '@nolebase/vitepress-plugin-page-properties/vite' 11} from '@nolebase/vitepress-plugin-page-properties/vite'
12import { fileURLToPath, URL } from 'node:url' 12import { fileURLToPath, URL } from 'node:url'
13import { parse as parseDomain } from 'tldts'
14import UnoCSS from 'unocss/vite' 13import UnoCSS from 'unocss/vite'
15import Devtools from 'vite-plugin-vue-devtools' 14import Devtools from 'vite-plugin-vue-devtools'
16import type { DefaultTheme, Plugin, UserConfig } from 'vitepress' 15import type { DefaultTheme, Plugin, UserConfig } from 'vitepress'
@@ -29,10 +28,6 @@ const GIT_COMMIT = process.env.NODE_ENV === 'development'
29 .then((result) => result.stdout.trim())) ?? 28 .then((result) => result.stdout.trim())) ??
30 'dev') 29 'dev')
31 30
32function siteName(host: string): string {
33 return parseDomain(host).domainWithoutSuffix ?? ''
34}
35
36export const shared: UserConfig<DefaultTheme.Config> = { 31export const shared: UserConfig<DefaultTheme.Config> = {
37 ...siteConfig, 32 ...siteConfig,
38 transformHead: async (context) => generateMeta(context, hostname), 33 transformHead: async (context) => generateMeta(context, hostname),
@@ -49,23 +44,30 @@ export const shared: UserConfig<DefaultTheme.Config> = {
49 search: { 44 search: {
50 options: { 45 options: {
51 miniSearch: { 46 miniSearch: {
52 async _render(src, env, md) { 47 _render(src, env, md) {
53 const html = await md.renderAsync(src, env) 48 const html = md.render(src, env)
54 if (env.frontmatter?.search === false) return '' 49 if (env.frontmatter?.search === false) return html
50 const BARE_TLDS = new Set([
51 'org', 'com', 'net', 'io', 'co', 'gg', 'tv', 'me', 'app',
52 'dev', 'xyz', 'info', 'moe', 'to', 'cc', 'fm', 'fr', 'jp'
53 ])
55 const seen = new Set<string>() 54 const seen = new Set<string>()
56 for (const m of html.matchAll(/href="([^"]+)"/g)) { 55 for (const m of html.matchAll(/href="([^"]+)"/g)) {
57 try { 56 try {
58 const host = new URL(m[1]).hostname.replace(/^www\./, '') 57 const u = new URL(m[1])
58 const host = u.hostname.replace(/^www\./, '')
59 if (!host) continue 59 if (!host) continue
60 seen.add(host) 60 seen.add(host)
61 const name = siteName(host) 61 const bare = host.split('.')[0]
62 if (name) seen.add(name) 62 if (bare && !BARE_TLDS.has(bare)) seen.add(bare)
63 } catch {} 63 } catch {
64 }
64 } 65 }
66 for (const t of [...seen]) if (BARE_TLDS.has(t)) seen.delete(t)
65 if (seen.size === 0) return html 67 if (seen.size === 0) return html
66 return `${html}\n<p class="vp-search-urls" aria-hidden="true" style="display:none">${[ 68 return `${html}\n<p class="vp-search-urls" aria-hidden="true" style="display:none">${
67 ...seen 69 [...seen].join(' ')
68 ].join(' ')}</p>` 70 }</p>`
69 }, 71 },
70 searchOptions: { 72 searchOptions: {
71 combineWith: 'AND', 73 combineWith: 'AND',
docs/.vitepress/theme/components/Search.vue +7 −6
@@ -210,9 +210,7 @@ watchDebounced(
210 const _result = index 210 const _result = index
211 .search( 211 .search(
212 queryForSearch, 212 queryForSearch,
213 isUrlQuery 213 isUrlQuery ? { combineWith: 'OR' } : undefined
214 ? { combineWith: 'AND', prefix: false, fuzzy: false }
215 : undefined
216 ) 214 )
217 .slice(0, 16) as (SearchResult & Result)[] 215 .slice(0, 16) as (SearchResult & Result)[]
218 enableNoResults.value = true 216 enableNoResults.value = true
@@ -566,13 +564,16 @@ function looksLikeUrl(query: string) {
566} 564}
567 565
568function normalizeUrlQuery(query: string) { 566function normalizeUrlQuery(query: string) {
569 return query 567 const cleaned = query
570 .trim() 568 .trim()
571 .replace(/^https?:\/\//i, '') 569 .replace(/^https?:\/\//i, '')
572 .replace(/^www\./i, '') 570 .replace(/^www\./i, '')
573 .replace(/[?#].*$/, '') 571 .replace(/[?#].*$/, '')
574 .replace(/\/.*$/, '') 572 .replace(/\/.*$/, '') // drop path, keep host only
575 .trim() 573 const host = cleaned.trim()
574 if (!host) return query.trim()
575 const bareName = host.split('.')[0]
576 return bareName && bareName !== host ? `${host} ${bareName}` : host
576} 577}
577 578
578function formMarkRegex(terms: Set<string>) { 579function formMarkRegex(terms: Set<string>) {
package.json −1
@@ -45,7 +45,6 @@
45 "reka-ui": "^2.6.0", 45 "reka-ui": "^2.6.0",
46 "takumi-js": "^1.1.2", 46 "takumi-js": "^1.1.2",
47 "tinyexec": "^1.0.1", 47 "tinyexec": "^1.0.1",
48 "tldts": "^7.4.2",
49 "ufo": "^1.6.1", 48 "ufo": "^1.6.1",
50 "unocss": "66.5.5", 49 "unocss": "66.5.5",
51 "vite": "^7.2.2", 50 "vite": "^7.2.2",
pnpm-lock.yaml +5 −16
@@ -104,9 +104,6 @@ importers:
104 tinyexec: 104 tinyexec:
105 specifier: ^1.0.1 105 specifier: ^1.0.1
106 version: 1.0.2 106 version: 1.0.2
107 tldts:
108 specifier: ^7.4.2
109 version: 7.4.2
110 ufo: 107 ufo:
111 specifier: ^1.6.1 108 specifier: ^1.6.1
112 version: 1.6.1 109 version: 1.6.1
@@ -3317,13 +3314,6 @@ packages:
3317 resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} 3314 resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==}
3318 engines: {node: '>=12.0.0'} 3315 engines: {node: '>=12.0.0'}
3319 3316
3320 tldts-core@7.4.2:
3321 resolution: {integrity: sha512-nwEyF4vl4RSJjwSjBUmOSxc3BFPoIFdlRthJ6e+5v9P3bHNsoD06UjuqMUspqp7vsEZ1beaHi1km+optiE17yA==}
3322
3323 tldts@7.4.2:
3324 resolution: {integrity: sha512-kCwffuaH8ntKtygnWe1b4BJKWiCUH30n5KfoTr6IchcXOwR7chAOFJxFrH3vjANafUYrIA4a7SDL+nn7SiR4Sw==}
3325 hasBin: true
3326
3327 to-regex-range@5.0.1: 3317 to-regex-range@5.0.1:
3328 resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} 3318 resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
3329 engines: {node: '>=8.0'} 3319 engines: {node: '>=8.0'}
@@ -3613,6 +3603,9 @@ packages:
3613 postcss: 3603 postcss:
3614 optional: true 3604 optional: true
3615 3605
3606 vscode-uri@3.1.0:
3607 resolution: {integrity: sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==}
3608
3616 vue-demi@0.14.10: 3609 vue-demi@0.14.10:
3617 resolution: {integrity: sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==} 3610 resolution: {integrity: sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==}
3618 engines: {node: '>=12'} 3611 engines: {node: '>=12'}
@@ -6817,12 +6810,6 @@ snapshots:
6817 fdir: 6.5.0(picomatch@4.0.3) 6810 fdir: 6.5.0(picomatch@4.0.3)
6818 picomatch: 4.0.3 6811 picomatch: 4.0.3
6819 6812
6820 tldts-core@7.4.2: {}
6821
6822 tldts@7.4.2:
6823 dependencies:
6824 tldts-core: 7.4.2
6825
6826 to-regex-range@5.0.1: 6813 to-regex-range@5.0.1:
6827 dependencies: 6814 dependencies:
6828 is-number: 7.0.0 6815 is-number: 7.0.0
@@ -7139,6 +7126,8 @@ snapshots:
7139 - universal-cookie 7126 - universal-cookie
7140 - yaml 7127 - yaml
7141 7128
7129 vscode-uri@3.1.0: {}
7130
7142 vue-demi@0.14.10(vue@3.5.24(typescript@5.6.3)): 7131 vue-demi@0.14.10(vue@3.5.24(typescript@5.6.3)):
7143 dependencies: 7132 dependencies:
7144 vue: 3.5.24(typescript@5.6.3) 7133 vue: 3.5.24(typescript@5.6.3)