Commit 7c81cf874b

7c81cf874b968aea4d1c391895f76bf000a68283

parent: c9e350253e

Unsigned

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

Revert "meme"

This reverts commit 66fac8678823448ec8d443efe31b8a97afa1b66e.

Layout: unified · split

docs/.vitepress/configs/index.ts +1 −26
@@ -44,31 +44,6 @@ export const shared: UserConfig<DefaultTheme.Config> = {
44 search: { 44 search: {
45 options: { 45 options: {
46 miniSearch: { 46 miniSearch: {
47 _render(src, env, md) {
48 const html = md.render(src, env)
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 ])
54 const seen = new Set<string>()
55 for (const m of html.matchAll(/href="([^"]+)"/g)) {
56 try {
57 const u = new URL(m[1])
58 const host = u.hostname.replace(/^www\./, '')
59 if (!host) continue
60 seen.add(host)
61 const bare = host.split('.')[0]
62 if (bare && !BARE_TLDS.has(bare)) seen.add(bare)
63 } catch {
64 }
65 }
66 for (const t of [...seen]) if (BARE_TLDS.has(t)) seen.delete(t)
67 if (seen.size === 0) return html
68 return `${html}\n<p class="vp-search-urls" aria-hidden="true" style="display:none">${
69 [...seen].join(' ')
70 }</p>`
71 },
72 searchOptions: { 47 searchOptions: {
73 combineWith: 'AND', 48 combineWith: 'AND',
74 fuzzy: false, 49 fuzzy: false,
@@ -173,4 +148,4 @@ export const shared: UserConfig<DefaultTheme.Config> = {
173 ] 148 ]
174 } 149 }
175 } 150 }
176}\ No newline at end of file 151}
docs/.vitepress/theme/components/Search.vue +2 −26
@@ -203,15 +203,8 @@ watchDebounced(
203 if (!index) return 203 if (!index) return
204 204
205 // Search 205 // Search
206 const isUrlQuery = looksLikeUrl(filterTextValue)
207 const queryForSearch = isUrlQuery
208 ? normalizeUrlQuery(filterTextValue)
209 : filterTextValue
210 const _result = index 206 const _result = index
211 .search( 207 .search(filterTextValue)
212 queryForSearch,
213 isUrlQuery ? { combineWith: 'OR' } : undefined
214 )
215 .slice(0, 16) as (SearchResult & Result)[] 208 .slice(0, 16) as (SearchResult & Result)[]
216 enableNoResults.value = true 209 enableNoResults.value = true
217 210
@@ -559,23 +552,6 @@ watch(
559 } 552 }
560) 553)
561 554
562function looksLikeUrl(query: string) {
563 return /https?:\/\/|www\.|[^\s]+\.[a-z]{2,}(\/|$)/i.test(query.trim())
564}
565
566function normalizeUrlQuery(query: string) {
567 const cleaned = query
568 .trim()
569 .replace(/^https?:\/\//i, '')
570 .replace(/^www\./i, '')
571 .replace(/[?#].*$/, '')
572 .replace(/\/.*$/, '') // drop path, keep host only
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
577}
578
579function formMarkRegex(terms: Set<string>) { 555function formMarkRegex(terms: Set<string>) {
580 return new RegExp( 556 return new RegExp(
581 [...terms] 557 [...terms]
@@ -1232,4 +1208,4 @@ svg {
1232 background-color: rgba(var(--vp-c-brand-1), 0.1); 1208 background-color: rgba(var(--vp-c-brand-1), 0.1);
1233 border-radius: 4px; 1209 border-radius: 4px;
1234} 1210}
1235</style>\ No newline at end of file 1211</style>