Commit 1f2dfae5f9

1f2dfae5f968c0e733bcc87e35741e3033cf18a0

parent: a2544f1719

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-06-03 15:21 UTC

ash again

https://youtu.be/twUFbqyul_M

Layout: unified · split

docs/.vitepress/configs/index.ts +2 −1
@@ -17,7 +17,7 @@ import { hostname, sidebar, siteConfig } from './constants'
1717import { generateImages, generateMeta } from './hooks'
1818import { configureMarkdown } from './markdown'
1919import { aliases, defs, movePlugin } from './markdown/emoji'
20import { collectPageLinks, writeUrlSearchIndex } from '../plugins/urlSearchPlugin'
20import { collectPageLinks, urlSearchDevPlugin, writeUrlSearchIndex } from '../plugins/urlSearchPlugin'
2121
2222const GIT_COMMIT = process.env.NODE_ENV === 'development'
2323 ? 'dev'
@@ -107,6 +107,7 @@ export const shared: UserConfig<DefaultTheme.Config> = {
107107 ]
108108 },
109109 plugins: [
110 urlSearchDevPlugin(),
110111 Devtools(),
111112 PageProperties(),
112113 PagePropertiesMarkdownSection(),
docs/.vitepress/plugins/urlSearchPlugin.ts +19
@@ -94,4 +94,23 @@ export function writeUrlSearchIndex(outDir: string) {
9494 const outPath = join(outDir, 'url-search-index.json')
9595 writeFileSync(outPath, JSON.stringify(deduped), 'utf-8')
9696 console.log(`[url-search] wrote ${deduped.length} links → ${outPath}`)
97}
98
99export function urlSearchDevPlugin() {
100 return {
101 name: 'url-search-dev',
102 configureServer(server: any) {
103 server.middlewares.use('/url-search-index.json', (_req: any, res: any) => {
104 const seen = new Set<string>()
105 const deduped = collected.filter((l) => {
106 const key = l.href + '\x00' + l.pageId + '\x00' + l.anchor
107 if (seen.has(key)) return false
108 seen.add(key)
109 return true
110 })
111 res.setHeader('Content-Type', 'application/json')
112 res.end(JSON.stringify(deduped))
113 })
114 }
115 }
97116}
\ No newline at end of file
docs/.vitepress/theme/components/Search.vue +640 −335
@@ -22,7 +22,6 @@ import { escapeRegExp } from 'vitepress/dist/client/shared'
2222import {
2323 computedAsync,
2424 onKeyStroke,
25 refDebounced,
2625 useEventListener,
2726 useLocalStorage,
2827 useScrollLock,
@@ -140,7 +139,19 @@ const filterText = disableQueryPersistence.value
140139 ? ref('')
141140 : useSessionStorage('vitepress:local-search-filter', '')
142141
143const debouncedFilterText = refDebounced(filterText, 300)
142const urlFilterDebounced = ref(filterText.value)
143let urlDebounceTimer: ReturnType<typeof setTimeout> | undefined
144watch(filterText, (v) => {
145 clearTimeout(urlDebounceTimer)
146 if (!v) {
147 urlFilterDebounced.value = '' // instant clear, no trailing-edge delay
148 return
149 }
150 urlDebounceTimer = setTimeout(() => {
151 urlFilterDebounced.value = v
152 }, 60)
153})
154onBeforeUnmount(() => clearTimeout(urlDebounceTimer))
144155
145156const showDetailedList = useLocalStorage(
146157 'vitepress:local-search-detailed-list',
@@ -196,18 +207,22 @@ interface UrlResult {
196207 highlighted: string
197208}
198209
199const urlResults = computed((): UrlResult[] => {
200 if (!urlSearchMode.value || !debouncedFilterText.value.trim()) return []
201 const query = debouncedFilterText.value.trim().toLowerCase()
202 const escaped = query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
203 const regex = new RegExp(`(${escaped})`, 'gi')
204 // allLinks is pre-sorted by page order — no sort needed here
205 return allLinks.value
206 .filter(({ href }) => href.toLowerCase().includes(query))
207 .map(({ href, linkText, pageId, anchor, titles }) => ({
208 href, linkText, pageId, anchor, titles,
209 highlighted: href.replace(regex, '<mark class="url-highlight">$1</mark>')
210 }))
210const URL_PAGE_SIZE = 50
211
212// 1-indexed current page within the URL results.
213const urlPage = ref(1)
214
215// Full match set — cheap string filtering only (no regex, no object churn).
216// Used for accurate page-group counts in the ribbon and for pagination.
217const urlMatches = computed((): PageLink[] => {
218 if (!urlSearchMode.value || !filterText.value.trim()) return []
219 const query = urlFilterDebounced.value.trim().toLowerCase()
220 if (!query) return []
221 const out: PageLink[] = []
222 for (const link of allLinks.value) {
223 if (link.href.toLowerCase().includes(query)) out.push(link)
224 }
225 return out
211226})
212227
213228// URL mode page ribbon — mirrors the normal pageGroups/filteredResults logic
@@ -215,7 +230,7 @@ const urlActivePageFilter = ref<string | null>(null)
215230
216231const urlPageGroups = computed(() => {
217232 const map = new Map<string, { key: string; label: string; count: number }>()
218 for (const r of urlResults.value) {
233 for (const r of urlMatches.value) {
219234 const key = r.pageId
220235 const existing = map.get(key)
221236 if (existing) existing.count++
@@ -224,24 +239,93 @@ const urlPageGroups = computed(() => {
224239 return [...map.values()].sort((a, b) => getPageOrder(a.key) - getPageOrder(b.key))
225240})
226241
227const filteredUrlResults = computed(() => {
228 if (!urlActivePageFilter.value) return urlResults.value
229 return urlResults.value.filter((r) => r.pageId === urlActivePageFilter.value)
242// Full match set honoring the active ribbon page filter (uncapped).
243const urlFilteredMatches = computed((): PageLink[] => {
244 if (!urlActivePageFilter.value) return urlMatches.value
245 return urlMatches.value.filter((l) => l.pageId === urlActivePageFilter.value)
246})
247
248// Total number of result pages (Google-style paging through urlFilteredMatches).
249const urlTotalPages = computed(() =>
250 Math.max(1, Math.ceil(urlFilteredMatches.value.length / URL_PAGE_SIZE))
251)
252
253// Clamp the current page whenever the result set shrinks.
254const urlCurrentPage = computed(() =>
255 Math.min(urlPage.value, urlTotalPages.value)
256)
257
258// The rows actually rendered: the current page's slice of the filtered matches.
259const filteredUrlResults = computed((): UrlResult[] => {
260 const matches = urlFilteredMatches.value
261 const start = (urlCurrentPage.value - 1) * URL_PAGE_SIZE
262 const end = start + URL_PAGE_SIZE
263 const out: UrlResult[] = []
264 for (let i = start; i < end && i < matches.length; i++) {
265 const link = matches[i]
266 out.push({
267 href: link.href,
268 linkText: link.linkText,
269 pageId: link.pageId,
270 anchor: link.anchor,
271 titles: link.titles,
272 highlighted: link.href // not currently rendered; kept for type compat
273 })
274 }
275 return out
276})
277
278// Compact page-number list with ellipses, e.g. [1, '…', 4, 5, 6, '…', 12].
279const urlPageList = computed<(number | '…')[]>(() => {
280 const total = urlTotalPages.value
281 const current = urlCurrentPage.value
282 if (total <= 7) return Array.from({ length: total }, (_, i) => i + 1)
283 const pages: (number | '…')[] = [1]
284 const left = Math.max(2, current - 1)
285 const right = Math.min(total - 1, current + 1)
286 if (left > 2) pages.push('…')
287 for (let p = left; p <= right; p++) pages.push(p)
288 if (right < total - 1) pages.push('…')
289 pages.push(total)
290 return pages
291})
292
293function goToUrlPage(p: number) {
294 const target = Math.min(Math.max(1, p), urlTotalPages.value)
295 if (target === urlCurrentPage.value) return
296 urlPage.value = target
297 selectedIndex.value = filteredUrlResults.value.length ? 1 : -1
298 nextTick(() => {
299 if (resultsEl.value) resultsEl.value.scrollTop = 0
300 scrollToSelectedResult()
301 })
302}
303
304// Reset to page 1 whenever the query changes or the page filter changes.
305watch([urlFilterDebounced, urlActivePageFilter], () => {
306 urlPage.value = 1
230307})
231308
232// Reset URL filter when query changes or mode switches
233watch(urlResults, (r) => {
234 if (urlActivePageFilter.value && !urlPageGroups.value.some((g) => g.key === urlActivePageFilter.value)) {
309// Reset URL ribbon filter if the active page disappears from the groups.
310watch(urlMatches, () => {
311 if (
312 urlActivePageFilter.value &&
313 !urlPageGroups.value.some((g) => g.key === urlActivePageFilter.value)
314 ) {
235315 urlActivePageFilter.value = null
236316 }
237317})
238318
239319watch(urlSearchMode, (active) => {
240 if (!active) urlActivePageFilter.value = null
320 if (!active) {
321 urlActivePageFilter.value = null
322 urlPage.value = 1
323 }
241324})
242325
243326function setUrlPageFilter(key: string | null) {
244327 urlActivePageFilter.value = urlActivePageFilter.value === key ? null : key
328 urlPage.value = 1
245329 selectedIndex.value = filteredUrlResults.value.length ? 1 : -1
246330 nextTick(() => {
247331 if (resultsEl.value) resultsEl.value.scrollTop = 0
@@ -364,6 +448,58 @@ const filteredResults = computed(() => {
364448 )
365449})
366450
451// --- Normal-mode (exact/fuzzy) pagination ---------------------------------
452// Mirrors the URL-mode pager. filteredResults stays the full filtered set;
453// pagedResults is the current page slice that actually renders.
454const NORMAL_PAGE_SIZE = URL_PAGE_SIZE
455
456const normalPage = ref(1)
457
458const normalTotalPages = computed(() =>
459 Math.max(1, Math.ceil(filteredResults.value.length / NORMAL_PAGE_SIZE))
460)
461
462const normalCurrentPage = computed(() =>
463 Math.min(normalPage.value, normalTotalPages.value)
464)
465
466const pagedResults = computed(() => {
467 const start = (normalCurrentPage.value - 1) * NORMAL_PAGE_SIZE
468 return filteredResults.value.slice(start, start + NORMAL_PAGE_SIZE)
469})
470
471const normalPageList = computed<(number | '…')[]>(() => {
472 const total = normalTotalPages.value
473 const current = normalCurrentPage.value
474 if (total <= 7) return Array.from({ length: total }, (_, i) => i + 1)
475 const pages: (number | '…')[] = [1]
476 const left = Math.max(2, current - 1)
477 const right = Math.min(total - 1, current + 1)
478 if (left > 2) pages.push('…')
479 for (let p = left; p <= right; p++) pages.push(p)
480 if (right < total - 1) pages.push('…')
481 pages.push(total)
482 return pages
483})
484
485function goToNormalPage(p: number) {
486 const target = Math.min(Math.max(1, p), normalTotalPages.value)
487 if (target === normalCurrentPage.value) return
488 normalPage.value = target
489 selectedIndex.value = pagedResults.value.length ? 1 : -1
490 nextTick(() => {
491 if (resultsEl.value) resultsEl.value.scrollTop = 0
492 scrollToSelectedResult()
493 reapplyHighlights()
494 })
495}
496
497// Reset to page 1 when the query changes (results replaced) or filter changes.
498watch([results, activePageFilter], () => {
499 normalPage.value = 1
500})
501// ---------------------------------------------------------------------------
502
367503function setPageFilter(key: string | null) {
368504 activePageFilter.value = activePageFilter.value === key ? null : key
369505 selectedIndex.value = filteredResults.value.length ? 1 : -1
@@ -842,12 +978,12 @@ function onSearchBarClick(event: PointerEvent) {
842978const selectedIndex = ref(-1)
843979const disableMouseOver = ref(true)
844980
845// Active result list length (URL mode vs normal mode)
981// Active result list length (URL mode vs normal mode) — current page only
846982const activeResultsLength = computed(() =>
847 urlSearchMode.value ? filteredUrlResults.value.length : filteredResults.value.length
983 urlSearchMode.value ? filteredUrlResults.value.length : pagedResults.value.length
848984)
849985
850watch(filteredResults, (r) => {
986watch(pagedResults, (r) => {
851987 if (!urlSearchMode.value) {
852988 selectedIndex.value = r.length ? 0 : -1
853989 scrollToSelectedResult()
@@ -918,7 +1054,7 @@ onKeyStroke('Enter', (e) => {
9181054 return
9191055 }
9201056
921 const selectedPackage = filteredResults.value[index]
1057 const selectedPackage = pagedResults.value[index]
9221058 if (e.target instanceof HTMLInputElement && !selectedPackage) {
9231059 e.preventDefault()
9241060 return
@@ -1051,346 +1187,396 @@ function onMouseMove(e: MouseEvent) {
10511187 v-if="showSearch"
10521188 class="shell"
10531189 >
1054 <form
1055 class="search-bar"
1056 @pointerup="onSearchBarClick($event)"
1057 @submit.prevent=""
1190 <form
1191 class="search-bar"
1192 @pointerup="onSearchBarClick($event)"
1193 @submit.prevent=""
1194 >
1195 <label
1196 :title="buttonText"
1197 id="localsearch-label"
1198 for="localsearch-input"
10581199 >
1059 <label
1060 :title="buttonText"
1061 id="localsearch-label"
1062 for="localsearch-input"
1200 <span
1201 aria-hidden="true"
1202 class="vpi-search search-icon local-search-icon"
1203 />
1204 </label>
1205 <div class="search-actions before">
1206 <button
1207 class="back-button"
1208 :title="translate('modal.backButtonTitle')"
1209 @click="showSearch = false"
10631210 >
1064 <span
1065 aria-hidden="true"
1066 class="vpi-search search-icon local-search-icon"
1067 />
1068 </label>
1069 <div class="search-actions before">
1211 <span class="vpi-arrow-left local-search-icon" />
1212 </button>
1213 </div>
1214 <input
1215 ref="searchInput"
1216 v-model="filterText"
1217 :aria-activedescendant="selectedIndex > -1
1218 ? 'localsearch-item-' + selectedIndex
1219 : undefined"
1220 aria-autocomplete="both"
1221 :aria-controls="results?.length ? 'localsearch-list' : undefined"
1222 aria-labelledby="localsearch-label"
1223 autocapitalize="off"
1224 autocomplete="off"
1225 autocorrect="off"
1226 class="search-input"
1227 id="localsearch-input"
1228 enterkeyhint="go"
1229 maxlength="64"
1230 :placeholder="buttonText"
1231 spellcheck="false"
1232 type="search"
1233 />
1234 <div class="search-actions">
1235 <div v-if="!disableDetailedView && searchMode !== 'url'" class="view-group toolbar-group">
1236 <button
1237 type="button"
1238 class="mode-btn"
1239 :class="{ 'mode-active': showDetailedList }"
1240 title="Detail view (Consumes more RAM)"
1241 @click="showDetailedList ? showDetailedList = false : showDetailedList = true"
1242 >
1243 <LayoutList :size="18" stroke-width="1.25" />
1244 </button>
10701245 <button
1071 class="back-button"
1072 :title="translate('modal.backButtonTitle')"
1073 @click="showSearch = false"
1246 type="button"
1247 class="mode-btn"
1248 :class="{ 'mode-active': !showDetailedList }"
1249 title="List view (Consumes less RAM)"
1250 @click="!showDetailedList ? showDetailedList = true : showDetailedList = false"
10741251 >
1075 <span class="vpi-arrow-left local-search-icon" />
1252 <List :size="18" stroke-width="1.25" />
10761253 </button>
10771254 </div>
1078 <input
1079 ref="searchInput"
1080 v-model="filterText"
1081 :aria-activedescendant="selectedIndex > -1
1082 ? 'localsearch-item-' + selectedIndex
1083 : undefined"
1084 aria-autocomplete="both"
1085 :aria-controls="results?.length ? 'localsearch-list' : undefined"
1086 aria-labelledby="localsearch-label"
1087 autocapitalize="off"
1088 autocomplete="off"
1089 autocorrect="off"
1090 class="search-input"
1091 id="localsearch-input"
1092 enterkeyhint="go"
1093 maxlength="64"
1094 :placeholder="buttonText"
1095 spellcheck="false"
1096 type="search"
1097 />
1098 <div class="search-actions">
1099 <div v-if="!disableDetailedView && searchMode !== 'url'" class="view-group toolbar-group">
1100 <button
1101 type="button"
1102 class="mode-btn"
1103 :class="{ 'mode-active': showDetailedList }"
1104 title="Detail view (Consumes more RAM)"
1105 @click="showDetailedList ? showDetailedList = false : showDetailedList = true"
1106 >
1107 <LayoutList :size="18" stroke-width="1.25" />
1108 </button>
1109 <button
1110 type="button"
1111 class="mode-btn"
1112 :class="{ 'mode-active': !showDetailedList }"
1113 title="List view (Consumes less RAM)"
1114 @click="!showDetailedList ? showDetailedList = true : showDetailedList = false"
1115 >
1116 <List :size="18" stroke-width="1.25" />
1117 </button>
1118 </div>
1119 <div class="search-mode-group toolbar-group">
1120 <button
1121 type="button"
1122 class="mode-btn"
1123 :class="{ 'mode-active': searchMode === 'exact' }"
1124 title="Exact search"
1125 @click="searchMode === 'exact' ? cycleSearchMode() : searchMode = 'exact'"
1126 >
1127 <Locate :size="18" stroke-width="1.25" />
1128 </button>
1129 <button
1130 type="button"
1131 class="mode-btn"
1132 :class="{ 'mode-active': searchMode === 'fuzzy' }"
1133 title="Fuzzy search"
1134 @click="searchMode === 'fuzzy' ? cycleSearchMode() : searchMode = 'fuzzy'"
1135 >
1136 <LocateOff :size="18" stroke-width="1.25" />
1137 </button>
1138 <button
1139 type="button"
1140 class="mode-btn"
1141 :class="{ 'mode-active': searchMode === 'url' }"
1142 title="URL search"
1143 @click="searchMode === 'url' ? cycleSearchMode() : searchMode = 'url'"
1144 >
1145 <Globe :size="18" stroke-width="1.25" />
1146 </button>
1147 </div>
1255 <div class="search-mode-group toolbar-group">
11481256 <button
1149 class="clear-button"
1150 type="reset"
1151 :disabled="disableReset"
1152 :title="translate('modal.resetButtonTitle')"
1153 @click="resetSearch"
1257 type="button"
1258 class="mode-btn"
1259 :class="{ 'mode-active': searchMode === 'exact' }"
1260 title="Exact search"
1261 @click="searchMode === 'exact' ? cycleSearchMode() : searchMode = 'exact'"
1262 >
1263 <Locate :size="18" stroke-width="1.25" />
1264 </button>
1265 <button
1266 type="button"
1267 class="mode-btn"
1268 :class="{ 'mode-active': searchMode === 'fuzzy' }"
1269 title="Fuzzy search"
1270 @click="searchMode === 'fuzzy' ? cycleSearchMode() : searchMode = 'fuzzy'"
1271 >
1272 <LocateOff :size="18" stroke-width="1.25" />
1273 </button>
1274 <button
1275 type="button"
1276 class="mode-btn"
1277 :class="{ 'mode-active': searchMode === 'url' }"
1278 title="URL search"
1279 @click="searchMode === 'url' ? cycleSearchMode() : searchMode = 'url'"
11541280 >
1155 <Delete :size="19" stroke-width="1.25" />
1281 <Globe :size="18" stroke-width="1.25" />
11561282 </button>
11571283 </div>
1158 </form>
1159
1284 <button
1285 class="clear-button"
1286 type="reset"
1287 :disabled="disableReset"
1288 :title="translate('modal.resetButtonTitle')"
1289 @click="resetSearch"
1290 >
1291 <Delete :size="19" stroke-width="1.25" />
1292 </button>
1293 </div>
1294 </form>
1295
1296 <div
1297 v-if="urlSearchMode ? urlPageGroups.length > 1 : pageGroups.length > 1"
1298 class="page-ribbon"
1299 >
1300 <button
1301 v-if="ribbonCanScrollLeft"
1302 type="button"
1303 class="page-ribbon-arrow left"
1304 aria-label="Scroll filters left"
1305 @click="scrollRibbon(-1)"
1306 >
1307 <ChevronRight :size="18" stroke-width="1.75" />
1308 </button>
11601309 <div
1161 v-if="urlSearchMode ? urlPageGroups.length > 1 : pageGroups.length > 1"
1162 class="page-ribbon"
1310 ref="ribbonTrack"
1311 class="page-ribbon-track"
1312 @scroll="updateRibbonOverflow"
11631313 >
1314 <!-- URL mode tabs -->
1315 <template v-if="urlSearchMode">
11641316 <button
1165 v-if="ribbonCanScrollLeft"
11661317 type="button"
1167 class="page-ribbon-arrow left"
1168 aria-label="Scroll filters left"
1169 @click="scrollRibbon(-1)"
1318 class="page-pill"
1319 :class="{ active: urlActivePageFilter === null }"
1320 @click="setUrlPageFilter(null)"
11701321 >
1171 <ChevronRight :size="18" stroke-width="1.75" />
1322 All
1323 <span class="page-pill-count">{{ urlMatches.length }}</span>
11721324 </button>
1173 <div
1174 ref="ribbonTrack"
1175 class="page-ribbon-track"
1176 @scroll="updateRibbonOverflow"
1325 <button
1326 v-for="group in urlPageGroups"
1327 :key="group.key"
1328 type="button"
1329 class="page-pill"
1330 :class="{ active: urlActivePageFilter === group.key }"
1331 @click="setUrlPageFilter(group.key)"
11771332 >
1178 <!-- URL mode tabs -->
1179 <template v-if="urlSearchMode">
1180 <button
1181 type="button"
1182 class="page-pill"
1183 :class="{ active: urlActivePageFilter === null }"
1184 @click="setUrlPageFilter(null)"
1185 >
1186 All
1187 <span class="page-pill-count">{{ urlResults.length }}</span>
1188 </button>
1189 <button
1190 v-for="group in urlPageGroups"
1191 :key="group.key"
1192 type="button"
1193 class="page-pill"
1194 :class="{ active: urlActivePageFilter === group.key }"
1195 @click="setUrlPageFilter(group.key)"
1196 >
1197 <span class="page-pill-label">{{ group.label }}</span>
1198 <span class="page-pill-count">{{ group.count }}</span>
1199 </button>
1200 </template>
1201 <!-- Normal mode tabs -->
1202 <template v-else>
1203 <button
1204 type="button"
1205 class="page-pill"
1206 :class="{ active: activePageFilter === null }"
1207 @click="setPageFilter(null)"
1208 >
1209 All
1210 <span class="page-pill-count">{{ results.length }}</span>
1211 </button>
1212 <button
1213 v-for="group in pageGroups"
1214 :key="group.key"
1215 type="button"
1216 class="page-pill"
1217 :class="{ active: activePageFilter === group.key }"
1218 @click="setPageFilter(group.key)"
1219 >
1220 <span class="page-pill-label">{{ group.label }}</span>
1221 <span class="page-pill-count">{{ group.count }}</span>
1222 </button>
1223 </template>
1224 </div>
1333 <span class="page-pill-label">{{ group.label }}</span>
1334 <span class="page-pill-count">{{ group.count }}</span>
1335 </button>
1336 </template>
1337 <!-- Normal mode tabs -->
1338 <template v-else>
12251339 <button
1226 v-if="ribbonCanScrollRight"
12271340 type="button"
1228 class="page-ribbon-arrow right"
1229 aria-label="Scroll filters right"
1230 @click="scrollRibbon(1)"
1341 class="page-pill"
1342 :class="{ active: activePageFilter === null }"
1343 @click="setPageFilter(null)"
12311344 >
1232 <ChevronRight :size="18" stroke-width="1.75" />
1345 All
1346 <span class="page-pill-count">{{ results.length }}</span>
12331347 </button>
1234 </div>
1348 <button
1349 v-for="group in pageGroups"
1350 :key="group.key"
1351 type="button"
1352 class="page-pill"
1353 :class="{ active: activePageFilter === group.key }"
1354 @click="setPageFilter(group.key)"
1355 >
1356 <span class="page-pill-label">{{ group.label }}</span>
1357 <span class="page-pill-count">{{ group.count }}</span>
1358 </button>
1359 </template>
1360 </div>
1361 <button
1362 v-if="ribbonCanScrollRight"
1363 type="button"
1364 class="page-ribbon-arrow right"
1365 aria-label="Scroll filters right"
1366 @click="scrollRibbon(1)"
1367 >
1368 <ChevronRight :size="18" stroke-width="1.75" />
1369 </button>
1370 </div>
12351371
1236 <ul
1237 ref="resultsEl"
1238 :id="results?.length ? 'localsearch-list' : undefined"
1239 :role="results?.length ? 'listbox' : undefined"
1240 :aria-labelledby="results?.length ? 'localsearch-label' : undefined"
1241 class="results"
1242 @mousemove="onMouseMove"
1372 <ul
1373 ref="resultsEl"
1374 :id="results?.length ? 'localsearch-list' : undefined"
1375 :role="results?.length ? 'listbox' : undefined"
1376 :aria-labelledby="results?.length ? 'localsearch-label' : undefined"
1377 class="results"
1378 @mousemove="onMouseMove"
1379 >
1380 <!-- Empty state (shared) -->
1381 <div
1382 v-if="urlSearchMode
1383 ? (!filterText || !urlMatches.length)
1384 : (!filterText || !filteredResults.length)"
1385 class="flex flex-col justify-center items-center h-47.5 gap-2 font-medium text-sm text-gray-500 dark:text-gray-300 m-auto md:mt-10 md:mb-6 opacity-90"
12431386 >
1244 <!-- Empty state (shared) -->
1245 <div
1246 v-if="urlSearchMode
1247 ? (!filterText || !urlResults.length)
1248 : (!filterText || !filteredResults.length)"
1249 class="flex flex-col justify-center items-center h-47.5 gap-2 font-medium text-sm text-gray-500 dark:text-gray-300 m-auto md:mt-10 md:mb-6 opacity-90"
1250 >
1251 <img
1252 class="h-40 object-contain object-center -translate-x-2"
1253 src="/asset/smolame.png"
1254 alt="Smol ame"
1255 />
1256 <h1 v-if="filterText">Couldn't find anything, try again?</h1>
1257 <h1 v-else>Looking for something?</h1>
1258 </div>
1387 <img
1388 class="h-40 object-contain object-center -translate-x-2"
1389 src="/asset/smolame.png"
1390 alt="Smol ame"
1391 />
1392 <h1 v-if="filterText">Couldn't find anything, try again?</h1>
1393 <h1 v-else>Looking for something?</h1>
1394 </div>
12591395
1260 <!-- URL search results -->
1261 <template v-if="urlSearchMode">
1262 <li
1263 v-for="(item, index) in filteredUrlResults"
1264 :key="item.href + item.pageId"
1265 class="result-layout"
1266 :id="'localsearch-item-' + (index + 1)"
1267 :aria-selected="selectedIndex === index + 1 ? 'true' : 'false'"
1268 role="option"
1396 <!-- URL search results -->
1397 <template v-if="urlSearchMode">
1398 <li
1399 v-for="(item, index) in filteredUrlResults"
1400 :key="'url-' + urlCurrentPage + '-' + item.pageId + '-' + item.anchor + '-' + index"
1401 class="result-layout"
1402 :id="'localsearch-item-' + (index + 1)"
1403 :aria-selected="selectedIndex === index + 1 ? 'true' : 'false'"
1404 role="option"
1405 >
1406 <a
1407 :href="item.anchor ? item.pageId + '#' + item.anchor : item.pageId"
1408 class="result"
1409 :class="{ selected: selectedIndex === index + 1 }"
1410 :aria-label="item.linkText || item.href"
1411 @mouseenter="!disableMouseOver && (selectedIndex = index + 1)"
1412 @focusin="selectedIndex = index + 1"
1413 @click="onResultClick"
1414 :data-index="index + 1"
12691415 >
1270 <a
1271 :href="item.anchor ? item.pageId + '#' + item.anchor : item.pageId"
1272 class="result"
1273 :class="{ selected: selectedIndex === index + 1 }"
1274 :aria-label="item.linkText || item.href"
1275 @mouseenter="!disableMouseOver && (selectedIndex = index + 1)"
1276 @focusin="selectedIndex = index + 1"
1277 @click="onResultClick"
1278 :data-index="index + 1"
1279 >
1280 <div>
1281 <div class="titles">
1282 <Hash v-if="item.titles.length > 0" stroke-width="1.25" :size="18" />
1283 <File v-else stroke-width="1.25" :size="18" />
1284 <span
1285 v-for="(t, ti) in item.titles"
1286 :key="ti"
1287 class="title"
1288 >
1289 <span class="text" v-html="t" />
1290 <ArrowRight stroke-width="1.25" :size="18" class="mx-0.5" />
1291 </span>
1292 <span class="title main">
1293 <span class="text">{{ item.linkText || item.href }}</span>
1294 </span>
1295 <a
1296 :href="item.href"
1297 target="_blank"
1298 rel="noopener noreferrer"
1299 class="url-open-btn"
1300 :class="{ 'url-open-btn-selected': selectedIndex === index + 1 }"
1301 title="Open link"
1302 @click.stop
1303 >
1304 <ExternalLink :size="14" stroke-width="1.5" />
1305 </a>
1306 </div>
1416 <div class="url-result-body">
1417 <div class="titles url-titles">
1418 <Hash v-if="item.titles.length > 0" stroke-width="1.25" :size="18" />
1419 <File v-else stroke-width="1.25" :size="18" />
1420 <span
1421 v-for="(t, ti) in item.titles"
1422 :key="ti"
1423 class="title"
1424 >
1425 <span class="text" v-html="t" />
1426 <ArrowRight stroke-width="1.25" :size="18" class="mx-0.5" />
1427 </span>
1428 <span class="title main">
1429 <span class="text">{{ item.linkText || item.href }}</span>
1430 </span>
13071431 </div>
1308 </a>
1309 </li>
1310 </template>
1311
1312 <!-- Normal search results -->
1313 <template v-else>
1314 <li
1315 v-for="(p, index) in filteredResults"
1316 :key="p.id"
1317 class="result-layout"
1318 :id="'localsearch-item-' + (index + 1)"
1319 :aria-selected="selectedIndex === index + 1 ? 'true' : 'false'"
1320 role="option"
1432 <a
1433 :href="item.href"
1434 target="_blank"
1435 rel="noopener noreferrer"
1436 class="url-open-btn"
1437 :class="{ 'url-open-btn-selected': selectedIndex === index + 1 }"
1438 title="Open link"
1439 @click.stop
1440 >
1441 <ExternalLink :size="14" stroke-width="1.5" />
1442 </a>
1443 </div>
1444 </a>
1445 </li>
1446 </template>
1447
1448 <!-- Normal search results -->
1449 <template v-else>
1450 <li
1451 v-for="(p, index) in pagedResults"
1452 :key="'normal-' + normalCurrentPage + '-' + p.id"
1453 class="result-layout"
1454 :id="'localsearch-item-' + (index + 1)"
1455 :aria-selected="selectedIndex === index + 1 ? 'true' : 'false'"
1456 role="option"
1457 >
1458 <a
1459 :href="p.id"
1460 class="result"
1461 :class="{ selected: selectedIndex === index + 1 }"
1462 :aria-label="[...p.titles, p.title].join(' > ')"
1463 @mouseenter="!disableMouseOver && (selectedIndex = index + 1)"
1464 @focusin="selectedIndex = index + 1"
1465 @click="onResultClick"
1466 :data-index="index + 1"
13211467 >
1322 <a
1323 :href="p.id"
1324 class="result"
1325 :class="{ selected: selectedIndex === index + 1 }"
1326 :aria-label="[...p.titles, p.title].join(' > ')"
1327 @mouseenter="!disableMouseOver && (selectedIndex = index + 1)"
1328 @focusin="selectedIndex = index + 1"
1329 @click="onResultClick"
1330 :data-index="index + 1"
1331 >
1332 <div>
1333 <div class="titles">
1334 <Hash v-if="p.titles.length > 0" stroke-width="1.25" :size="18" />
1335 <File v-else stroke-width="1.25" :size="18" />
1336 <span
1337 v-for="(t, index) in p.titles"
1338 :key="index"
1339 class="title"
1340 >
1341 <span class="text" v-html="t" />
1342 <ArrowRight stroke-width="1.25" :size="18" class="mx-0.5" />
1343 </span>
1344 <span class="title main">
1345 <span class="text" v-html="p.title" />
1346 </span>
1347 </div>
1468 <div>
1469 <div class="titles">
1470 <Hash v-if="p.titles.length > 0" stroke-width="1.25" :size="18" />
1471 <File v-else stroke-width="1.25" :size="18" />
1472 <span
1473 v-for="(t, index) in p.titles"
1474 :key="index"
1475 class="title"
1476 >
1477 <span class="text" v-html="t" />
1478 <ArrowRight stroke-width="1.25" :size="18" class="mx-0.5" />
1479 </span>
1480 <span class="title main">
1481 <span class="text" v-html="p.title" />
1482 </span>
1483 </div>
13481484
1349 <div v-if="showDetailedList" class="excerpt-wrapper">
1350 <div v-if="p.text" class="excerpt" inert>
1351 <div class="vp-doc" v-html="p.text" />
1352 </div>
1353 <div class="excerpt-gradient-bottom" />
1354 <div class="excerpt-gradient-top" />
1485 <div v-if="showDetailedList" class="excerpt-wrapper">
1486 <div v-if="p.text" class="excerpt" inert>
1487 <div class="vp-doc" v-html="p.text" />
13551488 </div>
1489 <div class="excerpt-gradient-bottom" />
1490 <div class="excerpt-gradient-top" />
13561491 </div>
1357 </a>
1358 </li>
1359 </template>
1360 </ul>
1361
1362 <div class="search-keyboard-shortcuts">
1363 <span>
1364 <kbd
1365 :aria-label="translate(
1366 'modal.footer.navigateUpKeyAriaLabel'
1367 )"
1368 >
1369 <span class="vpi-arrow-up navigate-icon" />
1370 </kbd>
1371 <kbd
1372 :aria-label="translate(
1373 'modal.footer.navigateDownKeyAriaLabel'
1374 )"
1492 </div>
1493 </a>
1494 </li>
1495 </template>
1496 </ul>
1497
1498 <!-- Pagination controls (Fixed structural segment block style wrapper) -->
1499 <nav
1500 v-if="(urlSearchMode ? urlTotalPages : normalTotalPages) > 1"
1501 class="url-pagination"
1502 aria-label="Search result pages"
1503 >
1504 <div class="url-pagination-segment">
1505 <button
1506 type="button"
1507 class="url-page-btn url-page-nav"
1508 :disabled="(urlSearchMode ? urlCurrentPage : normalCurrentPage) <= 1"
1509 aria-label="Previous page"
1510 @click="urlSearchMode
1511 ? goToUrlPage(urlCurrentPage - 1)
1512 : goToNormalPage(normalCurrentPage - 1)"
1513 >
1514 <ChevronRight :size="14" stroke-width="2" style="transform: rotate(180deg)" />
1515 </button>
1516
1517 <template
1518 v-for="(p, pi) in (urlSearchMode ? urlPageList : normalPageList)"
1519 :key="pi"
1520 >
1521 <span v-if="p === '…'" class="url-page-ellipsis">…</span>
1522 <button
1523 v-else
1524 type="button"
1525 class="url-page-btn"
1526 :class="{ active: p === (urlSearchMode ? urlCurrentPage : normalCurrentPage) }"
1527 :aria-current="p === (urlSearchMode ? urlCurrentPage : normalCurrentPage) ? 'page' : undefined"
1528 @click="urlSearchMode ? goToUrlPage(p as number) : goToNormalPage(p as number)"
13751529 >
1376 <span class="vpi-arrow-down navigate-icon" />
1377 </kbd>
1378 {{ translate('modal.footer.navigateText') }}
1379 </span>
1380 <span>
1381 <kbd :aria-label="translate('modal.footer.selectKeyAriaLabel')">
1382 <span class="vpi-corner-down-left navigate-icon" />
1383 </kbd>
1384 {{ translate('modal.footer.selectText') }}
1385 </span>
1386 <span>
1387 <kbd :aria-label="translate('modal.footer.closeKeyAriaLabel')">
1388 esc
1389 </kbd>
1390 {{ translate('modal.footer.closeText') }}
1391 </span>
1530 {{ p }}
1531 </button>
1532 </template>
1533
1534 <button
1535 type="button"
1536 class="url-page-btn url-page-nav"
1537 :disabled="(urlSearchMode ? urlCurrentPage : normalCurrentPage) >= (urlSearchMode ? urlTotalPages : normalTotalPages)"
1538 aria-label="Next page"
1539 @click="urlSearchMode
1540 ? goToUrlPage(urlCurrentPage + 1)
1541 : goToNormalPage(normalCurrentPage + 1)"
1542 >
1543 <ChevronRight :size="14" stroke-width="2" />
1544 </button>
13921545 </div>
1546 </nav>
1547
1548 <div class="search-keyboard-shortcuts">
1549 <span>
1550 <kbd
1551 :aria-label="translate(
1552 'modal.footer.navigateUpKeyAriaLabel'
1553 )"
1554 >
1555 <span class="vpi-arrow-up navigate-icon" />
1556 </kbd>
1557 <kbd
1558 :aria-label="translate(
1559 'modal.footer.navigateDownKeyAriaLabel'
1560 )"
1561 >
1562 <span class="vpi-arrow-down navigate-icon" />
1563 </kbd>
1564 {{ translate('modal.footer.navigateText') }}
1565 </span>
1566 <span>
1567 <kbd :aria-label="translate('modal.footer.selectKeyAriaLabel')">
1568 <span class="vpi-corner-down-left navigate-icon" />
1569 </kbd>
1570 {{ translate('modal.footer.selectText') }}
1571 </span>
1572 <span>
1573 <kbd :aria-label="translate('modal.footer.closeKeyAriaLabel')">
1574 esc
1575 </kbd>
1576 {{ translate('modal.footer.closeText') }}
1577 </span>
13931578 </div>
1579 </div>
13941580
13951581 <button v-if="!showSearch" />
13961582 </div>
@@ -1403,6 +1589,13 @@ function onMouseMove(e: MouseEvent) {
14031589 z-index: 100;
14041590 inset: 0;
14051591 display: flex;
1592 align-items: flex-start;
1593}
1594
1595@media (max-width: 767px) {
1596 .VPLocalSearchBox {
1597 align-items: stretch;
1598 }
14061599}
14071600
14081601.backdrop {
@@ -1413,6 +1606,7 @@ function onMouseMove(e: MouseEvent) {
14131606
14141607.shell {
14151608 position: relative;
1609 box-sizing: border-box;
14161610 padding: 12px;
14171611 margin: 64px auto;
14181612 display: flex;
@@ -1420,7 +1614,7 @@ function onMouseMove(e: MouseEvent) {
14201614 gap: 16px;
14211615 background: var(--vp-local-search-bg);
14221616 width: min(100vw - 60px, 900px);
1423 height: min-content;
1617 height: 100%;
14241618 max-height: min(100vh - 128px, 900px);
14251619 border-radius: 6px;
14261620}
@@ -1430,12 +1624,17 @@ function onMouseMove(e: MouseEvent) {
14301624 margin: 0;
14311625 width: 100vw;
14321626 height: 100vh;
1627 height: 100dvh;
14331628 max-height: none;
14341629 border-radius: 0;
1630 overflow: hidden;
1631 gap: 8px;
14351632 }
14361633}
14371634
14381635.search-bar {
1636 flex: 0 0 auto !important;
1637 min-height: 44px !important;
14391638 border: 1px solid var(--vp-c-divider);
14401639 border-radius: 4px;
14411640 display: flex;
@@ -1447,6 +1646,7 @@ function onMouseMove(e: MouseEvent) {
14471646@media (max-width: 767px) {
14481647 .search-bar {
14491648 padding: 0 8px;
1649 min-height: 40px !important;
14501650 }
14511651}
14521652
@@ -1687,6 +1887,8 @@ function onMouseMove(e: MouseEvent) {
16871887 display: flex;
16881888 flex-direction: column;
16891889 gap: 6px;
1890 flex: 1 1 auto;
1891 min-height: 0 !important;
16901892 overflow-x: hidden;
16911893 overflow-y: auto;
16921894 overscroll-behavior: contain;
@@ -1725,6 +1927,17 @@ function onMouseMove(e: MouseEvent) {
17251927 align-items: center;
17261928}
17271929
1930/* URL-mode card: breadcrumb text wraps freely, open-link button is pinned
1931 to the top-right corner so it never detaches when the title wraps. */
1932.url-result-body {
1933 position: relative;
1934 padding-right: 28px;
1935}
1936
1937.url-titles {
1938 z-index: auto;
1939}
1940
17281941.titles > svg {
17291942 flex-shrink: 0;
17301943 align-self: center;
@@ -1749,6 +1962,15 @@ function onMouseMove(e: MouseEvent) {
17491962 opacity: 0.5;
17501963}
17511964
1965.url-titles .title.main {
1966 min-width: 0;
1967}
1968
1969.url-titles .title.main .text {
1970 overflow-wrap: anywhere;
1971 word-break: break-word;
1972}
1973
17521974.result.selected {
17531975 --vp-local-search-result-bg: var(--vp-local-search-result-selected-bg);
17541976 border-color: var(--vp-local-search-result-selected-border);
@@ -1898,6 +2120,9 @@ svg {
18982120}
18992121
19002122.url-open-btn {
2123 position: absolute;
2124 top: 0;
2125 right: 0;
19012126 flex: none;
19022127 display: flex;
19032128 align-items: center;
@@ -1908,7 +2133,6 @@ svg {
19082133 color: var(--vp-c-text-3);
19092134 opacity: 0;
19102135 transition: opacity 0.15s, color 0.15s, background 0.15s;
1911 margin-left: auto;
19122136}
19132137
19142138.result:hover .url-open-btn,
@@ -1938,4 +2162,85 @@ svg {
19382162 padding: 0 2px;
19392163 font-style: normal;
19402164}
2165
2166/* Redesigned Unified Mode Switching Segmented Style Pagination Controls */
2167.url-pagination {
2168 display: flex;
2169 align-items: center;
2170 justify-content: center;
2171 flex: 0 0 auto !important;
2172 padding: 10px 8px;
2173 border-top: 1px solid var(--vp-c-divider);
2174}
2175
2176@media (max-width: 767px) {
2177 .url-pagination {
2178 padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
2179 }
2180}
2181
2182.url-pagination-segment {
2183 display: flex;
2184 align-items: center;
2185 border: 1px solid var(--vp-c-divider);
2186 border-radius: 5px;
2187 overflow: hidden;
2188 background: transparent;
2189}
2190
2191.url-page-btn {
2192 display: flex;
2193 align-items: center;
2194 justify-content: center;
2195 min-width: 32px;
2196 height: 28px;
2197 padding: 0 8px;
2198 border: none;
2199 background: transparent;
2200 color: var(--vp-c-text-2);
2201 font-size: 0.82rem;
2202 cursor: pointer;
2203 transition: color 0.15s, background-color 0.15s;
2204 border-radius: 0;
2205}
2206
2207.url-page-btn + .url-page-btn,
2208.url-page-ellipsis + .url-page-btn,
2209.url-page-btn + .url-page-ellipsis {
2210 border-left: 1px solid var(--vp-c-divider);
2211}
2212
2213.url-page-btn:hover:not(:disabled):not(.active) {
2214 color: var(--vp-c-text-1);
2215 background: var(--vp-c-default-soft);
2216}
2217
2218.url-page-btn.active {
2219 color: var(--vp-c-brand-1);
2220 background: rgba(60, 120, 210, 0.10);
2221 font-weight: 500;
2222 cursor: default;
2223}
2224
2225.url-page-btn:disabled {
2226 opacity: 0.25;
2227 cursor: not-allowed;
2228 background: transparent;
2229}
2230
2231.url-page-nav {
2232 padding: 0 6px;
2233}
2234
2235.url-page-ellipsis {
2236 display: flex;
2237 align-items: center;
2238 justify-content: center;
2239 min-width: 28px;
2240 height: 28px;
2241 color: var(--vp-c-text-3);
2242 font-size: 0.8rem;
2243 user-select: none;
2244 background: transparent;
2245}
19412246</style>
\ No newline at end of file