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> = {
4444 search: {
4545 options: {
4646 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 },
7247 searchOptions: {
7348 combineWith: 'AND',
7449 fuzzy: false,
@@ -173,4 +148,4 @@ export const shared: UserConfig<DefaultTheme.Config> = {
173148 ]
174149 }
175150 }
176}
\ No newline at end of file
151}
docs/.vitepress/theme/components/Search.vue +2 −26
@@ -203,15 +203,8 @@ watchDebounced(
203203 if (!index) return
204204
205205 // Search
206 const isUrlQuery = looksLikeUrl(filterTextValue)
207 const queryForSearch = isUrlQuery
208 ? normalizeUrlQuery(filterTextValue)
209 : filterTextValue
210206 const _result = index
211 .search(
212 queryForSearch,
213 isUrlQuery ? { combineWith: 'OR' } : undefined
214 )
207 .search(filterTextValue)
215208 .slice(0, 16) as (SearchResult & Result)[]
216209 enableNoResults.value = true
217210
@@ -559,23 +552,6 @@ watch(
559552 }
560553)
561554
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
579555function formMarkRegex(terms: Set<string>) {
580556 return new RegExp(
581557 [...terms]
@@ -1232,4 +1208,4 @@ svg {
12321208 background-color: rgba(var(--vp-c-brand-1), 0.1);
12331209 border-radius: 4px;
12341210}
1235</style>
\ No newline at end of file
1211</style>