| @@ -1,8 +1,9 @@ |
| 1 | 1 | <script lang="ts" setup> |
| 2 | 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 | 4 | import { |
| 5 | 5 | computed, |
| 6 | createApp, |
| 6 | 7 | markRaw, |
| 7 | 8 | nextTick, |
| 8 | 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 | 650 | if (showDetailedListValue) { |
| 646 | 651 | const eagerDocs = new Set<string>() |
| 647 | 652 | for (const r of _result.slice(0, EAGER_EXCERPTS)) { |
| @@ -1236,22 +1241,24 @@ function onMouseMove(e: MouseEvent) { |
| 1236 | 1241 | class="results" |
| 1237 | 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 | 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 | 1262 | <li |
| 1256 | 1263 | v-for="(item, index) in filteredUrlResults" |
| 1257 | 1264 | :key="item.href + item.pageId" |
| @@ -1262,7 +1269,7 @@ function onMouseMove(e: MouseEvent) { |
| 1262 | 1269 | > |
| 1263 | 1270 | <a |
| 1264 | 1271 | :href="item.anchor ? item.pageId + '#' + item.anchor : item.pageId" |
| 1265 | | class="result url-result" |
| 1272 | class="result" |
| 1266 | 1273 | :class="{ selected: selectedIndex === index + 1 }" |
| 1267 | 1274 | :aria-label="item.linkText || item.href" |
| 1268 | 1275 | @mouseenter="!disableMouseOver && (selectedIndex = index + 1)" |
| @@ -1270,36 +1277,33 @@ function onMouseMove(e: MouseEvent) { |
| 1270 | 1277 | @click="onResultClick" |
| 1271 | 1278 | :data-index="index + 1" |
| 1272 | 1279 | > |
| 1273 | | <div class="url-result-content"> |
| 1274 | | <div> |
| 1275 | | <div class="titles"> |
| 1276 | | <Hash v-if="item.titles.length > 0" stroke-width="1.25" :size="18" /> |
| 1277 | | <File v-else stroke-width="1.25" :size="18" /> |
| 1278 | | <span |
| 1279 | | v-for="(t, ti) in item.titles" |
| 1280 | | :key="ti" |
| 1281 | | class="title" |
| 1282 | | > |
| 1283 | | <span class="text" v-html="t" /> |
| 1284 | | <ArrowRight stroke-width="1.25" :size="18" class="mx-0.5" /> |
| 1285 | | </span> |
| 1286 | | <span class="title main"> |
| 1287 | | <span class="text">{{ item.linkText || item.href }}</span> |
| 1288 | | </span> |
| 1289 | | </div> |
| 1290 | | |
| 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> |
| 1291 | 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 | 1307 | </div> |
| 1304 | 1308 | </a> |
| 1305 | 1309 | </li> |
| @@ -1307,22 +1311,7 @@ function onMouseMove(e: MouseEvent) { |
| 1307 | 1311 | |
| 1308 | 1312 | <!-- Normal search results --> |
| 1309 | 1313 | <template v-else> |
| 1310 | | <div |
| 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 |
| 1314 | <li |
| 1326 | 1315 | v-for="(p, index) in filteredResults" |
| 1327 | 1316 | :key="p.id" |
| 1328 | 1317 | class="result-layout" |
| @@ -1333,36 +1322,24 @@ function onMouseMove(e: MouseEvent) { |
| 1333 | 1322 | <a |
| 1334 | 1323 | :href="p.id" |
| 1335 | 1324 | class="result" |
| 1336 | | :class="{ |
| 1337 | | selected: selectedIndex === index + 1 |
| 1338 | | }" |
| 1325 | :class="{ selected: selectedIndex === index + 1 }" |
| 1339 | 1326 | :aria-label="[...p.titles, p.title].join(' > ')" |
| 1340 | | @mouseenter="!disableMouseOver && |
| 1341 | | (selectedIndex = index + 1)" |
| 1327 | @mouseenter="!disableMouseOver && (selectedIndex = index + 1)" |
| 1342 | 1328 | @focusin="selectedIndex = index + 1" |
| 1343 | 1329 | @click="onResultClick" |
| 1344 | 1330 | :data-index="index + 1" |
| 1345 | 1331 | > |
| 1346 | 1332 | <div> |
| 1347 | 1333 | <div class="titles"> |
| 1348 | | <Hash |
| 1349 | | v-if="p.titles.length > 0" |
| 1350 | | stroke-width="1.25" |
| 1351 | | :size="18" |
| 1352 | | /> |
| 1334 | <Hash v-if="p.titles.length > 0" stroke-width="1.25" :size="18" /> |
| 1353 | 1335 | <File v-else stroke-width="1.25" :size="18" /> |
| 1354 | | |
| 1355 | 1336 | <span |
| 1356 | 1337 | v-for="(t, index) in p.titles" |
| 1357 | 1338 | :key="index" |
| 1358 | 1339 | class="title" |
| 1359 | 1340 | > |
| 1360 | 1341 | <span class="text" v-html="t" /> |
| 1361 | | <ArrowRight |
| 1362 | | stroke-width="1.25" |
| 1363 | | :size="18" |
| 1364 | | class="mx-0.5" |
| 1365 | | /> |
| 1342 | <ArrowRight stroke-width="1.25" :size="18" class="mx-0.5" /> |
| 1366 | 1343 | </span> |
| 1367 | 1344 | <span class="title main"> |
| 1368 | 1345 | <span class="text" v-html="p.title" /> |
| @@ -1370,11 +1347,7 @@ function onMouseMove(e: MouseEvent) { |
| 1370 | 1347 | </div> |
| 1371 | 1348 | |
| 1372 | 1349 | <div v-if="showDetailedList" class="excerpt-wrapper"> |
| 1373 | | <div |
| 1374 | | v-if="p.text" |
| 1375 | | class="excerpt" |
| 1376 | | inert |
| 1377 | | > |
| 1350 | <div v-if="p.text" class="excerpt" inert> |
| 1378 | 1351 | <div class="vp-doc" v-html="p.text" /> |
| 1379 | 1352 | </div> |
| 1380 | 1353 | <div class="excerpt-gradient-bottom" /> |
| @@ -1383,7 +1356,7 @@ function onMouseMove(e: MouseEvent) { |
| 1383 | 1356 | </div> |
| 1384 | 1357 | </a> |
| 1385 | 1358 | </li> |
| 1386 | | </template> |
| 1359 | </template> |
| 1387 | 1360 | </ul> |
| 1388 | 1361 | |
| 1389 | 1362 | <div class="search-keyboard-shortcuts"> |
| @@ -1918,30 +1891,18 @@ svg { |
| 1918 | 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 | 1894 | .url-open-btn { |
| 1934 | 1895 | flex: none; |
| 1935 | 1896 | display: flex; |
| 1936 | 1897 | align-items: center; |
| 1937 | 1898 | justify-content: center; |
| 1938 | | width: 28px; |
| 1939 | | height: 28px; |
| 1940 | | border-radius: 6px; |
| 1899 | width: 24px; |
| 1900 | height: 24px; |
| 1901 | border-radius: 4px; |
| 1941 | 1902 | color: var(--vp-c-text-3); |
| 1942 | 1903 | opacity: 0; |
| 1943 | 1904 | transition: opacity 0.15s, color 0.15s, background 0.15s; |
| 1944 | | margin-right: 4px; |
| 1905 | margin-left: auto; |
| 1945 | 1906 | } |
| 1946 | 1907 | |
| 1947 | 1908 | .result:hover .url-open-btn, |
| @@ -1964,21 +1925,6 @@ svg { |
| 1964 | 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 | 1928 | :deep(.url-highlight) { |
| 1983 | 1929 | background-color: var(--vp-local-search-highlight-bg); |
| 1984 | 1930 | color: var(--vp-local-search-highlight-text); |