mirror of
https://github.com/quartz-community/search.git
synced 2026-07-22 02:50:25 +00:00
No description
Subscribe to the content-index-updated CustomEvent and incrementally add newly-patched entries to the FlexSearch index. The existing indexInitialized memoization is preserved -- no full rebuild, just additive inserts via index.addAsync(), plus updates to idDataMap, contentData, and allTags. This enables runtime extension of the search index by other plugins. The primary consumer is @quartz-community/encrypted-pages, which patches the resolved fetchData object with decrypted entries from its shadow content index and dispatches content-index-updated so users can find and open decrypted pages via search within the same browser session. Non-fatal: the listener swallows errors from the in-place fetchData read and continues with whatever content-index data was loaded originally. |
||
|---|---|---|
| .github/workflows | ||
| dist | ||
| src | ||
| test | ||
| types | ||
| .eslintrc.json | ||
| .gitignore | ||
| .prettierignore | ||
| .prettierrc | ||
| CHANGELOG.md | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| tsconfig.build.json | ||
| tsconfig.json | ||
| tsup.config.ts | ||
| vitest.config.ts | ||
@quartz-community/search
The Search component for Quartz - full-text search with FlexSearch integration.
Features
- 🔍 Full-Text Search - Search across all your content instantly
- ⚡ Fast Indexing - Uses FlexSearch for high-performance search
- 📱 Mobile Responsive - Works great on all devices
- 🎯 Search Preview - Optional content preview panel
- 🌐 Multi-Language - Supports 30+ locales
- ⌨️ Keyboard Shortcuts -
Ctrl/Cmd + Kto open,Escapeto close - 🏷️ Tag Search - Search by tags with special syntax
Installation
npx quartz plugin add github:quartz-community/search
Usage
plugins:
- source: github:quartz-community/search
enabled: true
layout:
position: left
priority: 20
group: toolbar
groupOptions:
grow: true
For advanced use cases, you can override in TypeScript:
import * as ExternalPlugin from "./.quartz/plugins";
ExternalPlugin.Search({
enablePreview: true,
placeholder: "Search for something",
title: "Search",
});
Configuration Options
interface SearchOptions {
/** Enable content preview panel */
enablePreview?: boolean;
/** Custom placeholder text */
placeholder?: string;
/** Custom title for the search button */
title?: string;
}
Default Behavior
By default, the search component:
- Displays as a button with a search icon
- Opens a fullscreen search modal when clicked
- Shows up to 8 search results
- Enables content preview on desktop (can be disabled)
- Supports keyboard navigation (arrow keys, Enter, Escape)
- Uses FlexSearch from CDN for indexing
How It Works
The Search component:
- Loads FlexSearch library from CDN when initialized
- Fetches content data via the
fetchDataglobal (resolvescontentIndex.jsonwith the correct base path) - Builds a search index from your content
- Performs real-time search as you type
- Shows results with optional content preview
[!info] Search requires the
ContentIndexemitter plugin to be present in your Quartz configuration.
Keyboard Shortcuts
Ctrl/Cmd + K- Open/Close searchEscape- Close searchArrow Up/Down- Navigate resultsEnter- Open selected result
Development
This is a first-party Quartz community plugin. It serves as both:
- A production-ready Search component
- A reference implementation for building Quartz community plugins
To build locally:
npm install
npm run build
The prepare script automatically builds during installation.
Documentation
See the Quartz documentation for more information.
License
MIT