| @@ -1,8 +1,9 @@ |
| 1 | <script lang="ts" setup> |
1 | <script lang="ts" setup> |
| 2 | import MiniSearch, { type SearchResult } from 'minisearch' |
2 | import MiniSearch, { type SearchResult } from 'minisearch' |
| 3 | import { type DefaultTheme, inBrowser, useRouter } from 'vitepress' |
3 | import { type DefaultTheme, dataSymbol, inBrowser, useRouter } from 'vitepress' |
| 4 | import { |
4 | import { |
| 5 | computed, |
5 | computed, |
| |
6 | createApp, |
| 6 | markRaw, |
7 | markRaw, |
| 7 | nextTick, |
8 | nextTick, |
| 8 | onBeforeUnmount, |
9 | onBeforeUnmount, |
| @@ -642,6 +643,10 @@ watchDebounced( |
| 642 | } |
643 | } |
| 643 | } |
644 | } |
| 644 | |
645 | |
| |
646 | // Show results immediately (excerpts may be empty on first detail-view switch; |
| |
647 | // they fill in below once built) |
| |
648 | results.value = toRows(_result) |
| |
649 | |
| 645 | if (showDetailedListValue) { |
650 | if (showDetailedListValue) { |
| 646 | const eagerDocs = new Set<string>() |
651 | const eagerDocs = new Set<string>() |
| 647 | for (const r of _result.slice(0, EAGER_EXCERPTS)) { |
652 | for (const r of _result.slice(0, EAGER_EXCERPTS)) { |
| @@ -1236,22 +1241,24 @@ function onMouseMove(e: MouseEvent) { |
| 1236 | class="results" |
1241 | class="results" |
| 1237 | @mousemove="onMouseMove" |
1242 | @mousemove="onMouseMove" |
| 1238 | > |
1243 | > |
| 1239 | <!-- URL search mode results --> |
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> |
| |
1259 | |
| |
1260 | <!-- URL search results --> |
| 1240 | <template v-if="urlSearchMode"> |
1261 | <template v-if="urlSearchMode"> |
| 1241 | <div |
| |
| 1242 | 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" |
| |
| 1243 | v-if="!filterText || (filterText && !urlResults.length)" |
| |
| 1244 | > |
| |
| 1245 | <img |
| |
| 1246 | class="h-40 object-contain object-center -translate-x-2" |
| |
| 1247 | src="/asset/smolame.png" |
| |
| 1248 | alt="Smol ame" |
| |
| 1249 | /> |
| |
| 1250 | <h1 v-if="filterText && !urlResults.length"> |
| |
| 1251 | Couldn't find anything, try again? |
| |
| 1252 | </h1> |
| |
| 1253 | <h1 v-else>Looking for something?</h1> |
| |
| 1254 | </div> |
| |
| 1255 | <li |
1262 | <li |
| 1256 | v-for="(item, index) in filteredUrlResults" |
1263 | v-for="(item, index) in filteredUrlResults" |
| 1257 | :key="item.href + item.pageId" |
1264 | :key="item.href + item.pageId" |
| @@ -1262,7 +1269,7 @@ function onMouseMove(e: MouseEvent) { |
| 1262 | > |
1269 | > |
| 1263 | <a |
1270 | <a |
| 1264 | :href="item.anchor ? item.pageId + '#' + item.anchor : item.pageId" |
1271 | :href="item.anchor ? item.pageId + '#' + item.anchor : item.pageId" |
| 1265 | class="result url-result" |
1272 | class="result" |
| 1266 | :class="{ selected: selectedIndex === index + 1 }" |
1273 | :class="{ selected: selectedIndex === index + 1 }" |
| 1267 | :aria-label="item.linkText || item.href" |
1274 | :aria-label="item.linkText || item.href" |
| 1268 | @mouseenter="!disableMouseOver && (selectedIndex = index + 1)" |
1275 | @mouseenter="!disableMouseOver && (selectedIndex = index + 1)" |
| @@ -1270,36 +1277,33 @@ function onMouseMove(e: MouseEvent) { |
| 1270 | @click="onResultClick" |
1277 | @click="onResultClick" |
| 1271 | :data-index="index + 1" |
1278 | :data-index="index + 1" |
| 1272 | > |
1279 | > |
| 1273 | <div class="url-result-content"> |
1280 | <div> |
| 1274 | <div> |
1281 | <div class="titles"> |
| 1275 | <div class="titles"> |
1282 | <Hash v-if="item.titles.length > 0" stroke-width="1.25" :size="18" /> |
| 1276 | <Hash v-if="item.titles.length > 0" stroke-width="1.25" :size="18" /> |
1283 | <File v-else stroke-width="1.25" :size="18" /> |
| 1277 | <File v-else stroke-width="1.25" :size="18" /> |
1284 | <span |
| 1278 | <span |
1285 | v-for="(t, ti) in item.titles" |
| 1279 | v-for="(t, ti) in item.titles" |
1286 | :key="ti" |
| 1280 | :key="ti" |
1287 | class="title" |
| 1281 | class="title" |
1288 | > |
| 1282 | > |
1289 | <span class="text" v-html="t" /> |
| 1283 | <span class="text" v-html="t" /> |
1290 | <ArrowRight stroke-width="1.25" :size="18" class="mx-0.5" /> |
| 1284 | <ArrowRight stroke-width="1.25" :size="18" class="mx-0.5" /> |
1291 | </span> |
| 1285 | </span> |
1292 | <span class="title main"> |
| 1286 | <span class="title main"> |
1293 | <span class="text">{{ item.linkText || item.href }}</span> |
| 1287 | <span class="text">{{ item.linkText || item.href }}</span> |
1294 | </span> |
| 1288 | </span> |
1295 | <a |
| 1289 | </div> |
1296 | :href="item.href" |
| 1290 | |
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> |
| 1291 | </div> |
1306 | </div> |
| 1292 | <a |
| |
| 1293 | :href="item.href" |
| |
| 1294 | target="_blank" |
| |
| 1295 | rel="noopener noreferrer" |
| |
| 1296 | class="url-open-btn" |
| |
| 1297 | :class="{ 'url-open-btn-selected': selectedIndex === index + 1 }" |
| |
| 1298 | title="Open link" |
| |
| 1299 | @click.stop |
| |
| 1300 | > |
| |
| 1301 | <ExternalLink :size="14" stroke-width="1.5" /> |
| |
| 1302 | </a> |
| |
| 1303 | </div> |
1307 | </div> |
| 1304 | </a> |
1308 | </a> |
| 1305 | </li> |
1309 | </li> |
| @@ -1307,22 +1311,7 @@ function onMouseMove(e: MouseEvent) { |
| 1307 | |
1311 | |
| 1308 | <!-- Normal search results --> |
1312 | <!-- Normal search results --> |
| 1309 | <template v-else> |
1313 | <template v-else> |
| 1310 | <div |
1314 | <li |
| 1311 | 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" |
| |
| 1312 | v-if="!filterText || (filterText && !filteredResults.length)" |
| |
| 1313 | > |
| |
| 1314 | <img |
| |
| 1315 | class="h-40 object-contain object-center -translate-x-2" |
| |
| 1316 | src="/asset/smolame.png" |
| |
| 1317 | alt="Smol ame" |
| |
| 1318 | /> |
| |
| 1319 | <h1 v-if="filterText && !filteredResults.length"> |
| |
| 1320 | Couldn't find anything, try again? |
| |
| 1321 | </h1> |
| |
| 1322 | <h1 v-else>Looking for something?</h1> |
| |
| 1323 | </div> |
| |
| 1324 | |
| |
| 1325 | <li |
| |
| 1326 | v-for="(p, index) in filteredResults" |
1315 | v-for="(p, index) in filteredResults" |
| 1327 | :key="p.id" |
1316 | :key="p.id" |
| 1328 | class="result-layout" |
1317 | class="result-layout" |
| @@ -1333,36 +1322,24 @@ function onMouseMove(e: MouseEvent) { |
| 1333 | <a |
1322 | <a |
| 1334 | :href="p.id" |
1323 | :href="p.id" |
| 1335 | class="result" |
1324 | class="result" |
| 1336 | :class="{ |
1325 | :class="{ selected: selectedIndex === index + 1 }" |
| 1337 | selected: selectedIndex === index + 1 |
| |
| 1338 | }" |
| |
| 1339 | :aria-label="[...p.titles, p.title].join(' > ')" |
1326 | :aria-label="[...p.titles, p.title].join(' > ')" |
| 1340 | @mouseenter="!disableMouseOver && |
1327 | @mouseenter="!disableMouseOver && (selectedIndex = index + 1)" |
| 1341 | (selectedIndex = index + 1)" |
| |
| 1342 | @focusin="selectedIndex = index + 1" |
1328 | @focusin="selectedIndex = index + 1" |
| 1343 | @click="onResultClick" |
1329 | @click="onResultClick" |
| 1344 | :data-index="index + 1" |
1330 | :data-index="index + 1" |
| 1345 | > |
1331 | > |
| 1346 | <div> |
1332 | <div> |
| 1347 | <div class="titles"> |
1333 | <div class="titles"> |
| 1348 | <Hash |
1334 | <Hash v-if="p.titles.length > 0" stroke-width="1.25" :size="18" /> |
| 1349 | v-if="p.titles.length > 0" |
| |
| 1350 | stroke-width="1.25" |
| |
| 1351 | :size="18" |
| |
| 1352 | /> |
| |
| 1353 | <File v-else stroke-width="1.25" :size="18" /> |
1335 | <File v-else stroke-width="1.25" :size="18" /> |
| 1354 | |
| |
| 1355 | <span |
1336 | <span |
| 1356 | v-for="(t, index) in p.titles" |
1337 | v-for="(t, index) in p.titles" |
| 1357 | :key="index" |
1338 | :key="index" |
| 1358 | class="title" |
1339 | class="title" |
| 1359 | > |
1340 | > |
| 1360 | <span class="text" v-html="t" /> |
1341 | <span class="text" v-html="t" /> |
| 1361 | <ArrowRight |
1342 | <ArrowRight stroke-width="1.25" :size="18" class="mx-0.5" /> |
| 1362 | stroke-width="1.25" |
| |
| 1363 | :size="18" |
| |
| 1364 | class="mx-0.5" |
| |
| 1365 | /> |
| |
| 1366 | </span> |
1343 | </span> |
| 1367 | <span class="title main"> |
1344 | <span class="title main"> |
| 1368 | <span class="text" v-html="p.title" /> |
1345 | <span class="text" v-html="p.title" /> |
| @@ -1370,11 +1347,7 @@ function onMouseMove(e: MouseEvent) { |
| 1370 | </div> |
1347 | </div> |
| 1371 | |
1348 | |
| 1372 | <div v-if="showDetailedList" class="excerpt-wrapper"> |
1349 | <div v-if="showDetailedList" class="excerpt-wrapper"> |
| 1373 | <div |
1350 | <div v-if="p.text" class="excerpt" inert> |
| 1374 | v-if="p.text" |
| |
| 1375 | class="excerpt" |
| |
| 1376 | inert |
| |
| 1377 | > |
| |
| 1378 | <div class="vp-doc" v-html="p.text" /> |
1351 | <div class="vp-doc" v-html="p.text" /> |
| 1379 | </div> |
1352 | </div> |
| 1380 | <div class="excerpt-gradient-bottom" /> |
1353 | <div class="excerpt-gradient-bottom" /> |
| @@ -1383,7 +1356,7 @@ function onMouseMove(e: MouseEvent) { |
| 1383 | </div> |
1356 | </div> |
| 1384 | </a> |
1357 | </a> |
| 1385 | </li> |
1358 | </li> |
| 1386 | </template> |
1359 | </template> |
| 1387 | </ul> |
1360 | </ul> |
| 1388 | |
1361 | |
| 1389 | <div class="search-keyboard-shortcuts"> |
1362 | <div class="search-keyboard-shortcuts"> |
| @@ -1918,30 +1891,18 @@ svg { |
| 1918 | background: rgba(60, 120, 210, 0.10); |
1891 | background: rgba(60, 120, 210, 0.10); |
| 1919 | } |
1892 | } |
| 1920 | |
1893 | |
| 1921 | .url-result-content { |
| |
| 1922 | display: flex; |
| |
| 1923 | align-items: center; |
| |
| 1924 | width: 100%; |
| |
| 1925 | gap: 8px; |
| |
| 1926 | } |
| |
| 1927 | |
| |
| 1928 | .url-result-content > div:first-child { |
| |
| 1929 | flex: 1; |
| |
| 1930 | min-width: 0; |
| |
| 1931 | } |
| |
| 1932 | |
| |
| 1933 | .url-open-btn { |
1894 | .url-open-btn { |
| 1934 | flex: none; |
1895 | flex: none; |
| 1935 | display: flex; |
1896 | display: flex; |
| 1936 | align-items: center; |
1897 | align-items: center; |
| 1937 | justify-content: center; |
1898 | justify-content: center; |
| 1938 | width: 28px; |
1899 | width: 24px; |
| 1939 | height: 28px; |
1900 | height: 24px; |
| 1940 | border-radius: 6px; |
1901 | border-radius: 4px; |
| 1941 | color: var(--vp-c-text-3); |
1902 | color: var(--vp-c-text-3); |
| 1942 | opacity: 0; |
1903 | opacity: 0; |
| 1943 | transition: opacity 0.15s, color 0.15s, background 0.15s; |
1904 | transition: opacity 0.15s, color 0.15s, background 0.15s; |
| 1944 | margin-right: 4px; |
1905 | margin-left: auto; |
| 1945 | } |
1906 | } |
| 1946 | |
1907 | |
| 1947 | .result:hover .url-open-btn, |
1908 | .result:hover .url-open-btn, |
| @@ -1964,21 +1925,6 @@ svg { |
| 1964 | color: var(--vp-c-brand-1) !important; |
1925 | color: var(--vp-c-brand-1) !important; |
| 1965 | } |
1926 | } |
| 1966 | |
1927 | |
| 1967 | .url-excerpt { |
| |
| 1968 | height: auto !important; |
| |
| 1969 | max-height: none !important; |
| |
| 1970 | overflow: visible !important; |
| |
| 1971 | } |
| |
| 1972 | |
| |
| 1973 | .url-excerpt-href { |
| |
| 1974 | font-size: 0.78rem !important; |
| |
| 1975 | font-family: var(--vp-font-family-mono, monospace); |
| |
| 1976 | color: var(--vp-c-text-2); |
| |
| 1977 | word-break: break-all; |
| |
| 1978 | line-height: 1.5; |
| |
| 1979 | padding: 2px 0; |
| |
| 1980 | } |
| |
| 1981 | |
| |
| 1982 | :deep(.url-highlight) { |
1928 | :deep(.url-highlight) { |
| 1983 | background-color: var(--vp-local-search-highlight-bg); |
1929 | background-color: var(--vp-local-search-highlight-bg); |
| 1984 | color: var(--vp-local-search-highlight-text); |
1930 | color: var(--vp-local-search-highlight-text); |