The Trans Directory
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: index setup, styling fixes

+31 -35
+30 -33
quartz/components/scripts/search.inline.ts
··· 128 128 129 129 const data = await fetchData 130 130 const container = document.getElementById("search-container") 131 + const searchSpace = document.getElementById("search-space") 131 132 const sidebar = container?.closest(".sidebar") as HTMLElement 132 133 const searchIcon = document.getElementById("search-icon") 133 134 const searchBar = document.getElementById("search-bar") as HTMLInputElement | null ··· 170 171 removeAllChildren(preview) 171 172 } 172 173 if (searchLayout) { 173 - searchLayout.style.opacity = "0" 174 + searchLayout.style.visibility = "hidden" 174 175 } 175 176 176 177 searchType = "basic" // reset search type after closing ··· 449 450 currentSearchTerm = (e.target as HTMLInputElement).value 450 451 451 452 if (searchLayout) { 452 - searchLayout.style.opacity = "1" 453 + searchLayout.style.visibility = "visible" 453 454 } 454 455 455 456 if (term === "" && searchLayout) { 456 - searchLayout.style.opacity = "0" 457 + searchLayout.style.visibility = "hidden" 457 458 } 458 459 459 460 if (term.toLowerCase().startsWith("#")) { ··· 503 504 searchBar?.addEventListener("input", onType) 504 505 window.addCleanup(() => searchBar?.removeEventListener("input", onType)) 505 506 506 - // setup index if it hasn't been already 507 - if (!index) { 508 - index = new FlexSearch.Document({ 509 - charset: "latin:extra", 510 - encode: encoder, 511 - document: { 512 - id: "id", 513 - index: [ 514 - { 515 - field: "title", 516 - tokenize: "forward", 517 - }, 518 - { 519 - field: "content", 520 - tokenize: "forward", 521 - }, 522 - { 523 - field: "tags", 524 - tokenize: "forward", 525 - }, 526 - ], 527 - }, 528 - }) 529 - 530 - fillDocument(index, data) 531 - } 532 - 533 - // register handlers 534 - registerEscapeHandler(container, hideSearch) 507 + index ??= await fillDocument(data) 508 + registerEscapeHandler(searchSpace, hideSearch) 535 509 }) 536 510 537 511 /** ··· 539 513 * @param index index to fill 540 514 * @param data data to fill index with 541 515 */ 542 - async function fillDocument(index: FlexSearch.Document<Item, false>, data: any) { 516 + async function fillDocument(data: { [key: FullSlug]: ContentDetails }) { 517 + const index = new FlexSearch.Document<Item>({ 518 + charset: "latin:extra", 519 + encode: encoder, 520 + document: { 521 + id: "id", 522 + index: [ 523 + { 524 + field: "title", 525 + tokenize: "forward", 526 + }, 527 + { 528 + field: "content", 529 + tokenize: "forward", 530 + }, 531 + { 532 + field: "tags", 533 + tokenize: "forward", 534 + }, 535 + ], 536 + }, 537 + }) 543 538 let id = 0 544 539 for (const [slug, fileData] of Object.entries<ContentDetails>(data)) { 545 540 await index.addAsync(id++, { ··· 550 545 tags: fileData.tags, 551 546 }) 552 547 } 548 + 549 + return index 553 550 }
+1 -1
quartz/components/styles/search.scss
··· 85 85 & > #search-layout { 86 86 display: flex; 87 87 flex-direction: row; 88 - opacity: 0; 88 + visibility: hidden; 89 89 border: 1px solid var(--lightgray); 90 90 91 91 & > div {
-1
quartz/plugins/emitters/contentIndex.ts
··· 5 5 import { FilePath, FullSlug, SimpleSlug, joinSegments, simplifySlug } from "../../util/path" 6 6 import { QuartzEmitterPlugin } from "../types" 7 7 import { toHtml } from "hast-util-to-html" 8 - import path from "path" 9 8 import { write } from "./helpers" 10 9 11 10 export type ContentIndex = Map<FullSlug, ContentDetails>