2026-02-07 06:37:21 +00:00
|
|
|
# @quartz-community/search
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
The Search component for Quartz - full-text search with FlexSearch integration.
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
## Features
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
- 🔍 **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 + K` to open, `Escape` to close
|
|
|
|
|
- 🏷️ **Tag Search** - Search by tags with special syntax
|
|
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
2026-02-07 06:31:38 +00:00
|
|
|
```bash
|
2026-02-25 15:07:11 +00:00
|
|
|
npx quartz plugin add github:quartz-community/search
|
2026-02-07 06:31:38 +00:00
|
|
|
```
|
|
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
## Usage
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-25 15:07:11 +00:00
|
|
|
```yaml title="quartz.config.yaml"
|
|
|
|
|
plugins:
|
|
|
|
|
- source: github:quartz-community/search
|
|
|
|
|
enabled: true
|
|
|
|
|
layout:
|
|
|
|
|
position: left
|
|
|
|
|
priority: 20
|
|
|
|
|
group: toolbar
|
|
|
|
|
groupOptions:
|
|
|
|
|
grow: true
|
2026-02-07 06:31:38 +00:00
|
|
|
```
|
|
|
|
|
|
2026-02-25 15:07:11 +00:00
|
|
|
For advanced use cases, you can override in TypeScript:
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-25 15:07:11 +00:00
|
|
|
```ts title="quartz.ts (override)"
|
|
|
|
|
import * as ExternalPlugin from "./.quartz/plugins";
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-25 15:07:11 +00:00
|
|
|
ExternalPlugin.Search({
|
2026-02-07 06:37:21 +00:00
|
|
|
enablePreview: true,
|
|
|
|
|
placeholder: "Search for something",
|
|
|
|
|
title: "Search",
|
2026-02-07 06:31:38 +00:00
|
|
|
});
|
2026-02-07 06:37:21 +00:00
|
|
|
```
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
## Configuration Options
|
|
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
|
interface SearchOptions {
|
|
|
|
|
/** Enable content preview panel */
|
|
|
|
|
enablePreview?: boolean;
|
|
|
|
|
/** Custom placeholder text */
|
|
|
|
|
placeholder?: string;
|
|
|
|
|
/** Custom title for the search button */
|
|
|
|
|
title?: string;
|
|
|
|
|
}
|
2026-02-07 06:31:38 +00:00
|
|
|
```
|
|
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
## Default Behavior
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
By default, the search component:
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
- 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
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
## How It Works
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
The Search component:
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
1. Loads FlexSearch library from CDN when initialized
|
2026-03-16 17:54:25 +00:00
|
|
|
2. Fetches content data via the `fetchData` global (resolves `contentIndex.json` with the correct base path)
|
2026-02-07 06:37:21 +00:00
|
|
|
3. Builds a search index from your content
|
|
|
|
|
4. Performs real-time search as you type
|
|
|
|
|
5. Shows results with optional content preview
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
> [!info]
|
|
|
|
|
> Search requires the `ContentIndex` emitter plugin to be present in your Quartz configuration.
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
## Keyboard Shortcuts
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
- `Ctrl/Cmd + K` - Open/Close search
|
|
|
|
|
- `Escape` - Close search
|
|
|
|
|
- `Arrow Up/Down` - Navigate results
|
|
|
|
|
- `Enter` - Open selected result
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
## Development
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
This is a first-party Quartz community plugin. It serves as both:
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
1. A production-ready Search component
|
|
|
|
|
2. A reference implementation for building Quartz community plugins
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
To build locally:
|
2026-02-07 06:31:38 +00:00
|
|
|
|
|
|
|
|
```bash
|
2026-02-07 06:37:21 +00:00
|
|
|
npm install
|
2026-02-07 06:31:38 +00:00
|
|
|
npm run build
|
|
|
|
|
```
|
|
|
|
|
|
2026-02-07 06:37:21 +00:00
|
|
|
The `prepare` script automatically builds during installation.
|
2026-02-07 06:31:38 +00:00
|
|
|
|
2026-02-25 15:07:11 +00:00
|
|
|
## Documentation
|
|
|
|
|
|
|
|
|
|
See the [Quartz documentation](https://quartz.jzhao.xyz/features/full-text%20search) for more information.
|
|
|
|
|
|
2026-02-07 06:31:38 +00:00
|
|
|
## License
|
|
|
|
|
|
|
|
|
|
MIT
|