mirror of
https://github.com/quartz-community/search.git
synced 2026-07-22 02:50:25 +00:00
No description
- Add flexsearch as direct dependency - Remove external: ['flexsearch'] from esbuild config - Flexsearch must be bundled for browser runtime |
||
|---|---|---|
| .github/workflows | ||
| src | ||
| test | ||
| types | ||
| .eslintrc.json | ||
| .gitignore | ||
| .prettierrc | ||
| CHANGELOG.md | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| tsup.config.ts | ||
| vitest.config.ts | ||
@quartz-community/search
The Search component for Quartz - full-text search with FlexSearch integration.
This is a first-party community plugin for Quartz, demonstrating the new plugin system that allows components to be distributed as npm packages. It provides instant full-text search across your content using FlexSearch for fast indexing and retrieval.
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
From GitHub (Recommended for now)
npm install github:quartz-community/search --legacy-peer-deps
From NPM (when published)
npm install @quartz-community/search
Usage
1. Configure in quartz.config.ts
Add the plugin to your externalPlugins array:
// quartz.config.ts
import { QuartzConfig } from "./quartz/cfg";
const config: QuartzConfig = {
configuration: {
// ... your configuration
},
plugins: {
// ... your existing plugins
},
externalPlugins: ["@quartz-community/search"],
};
export default config;
2. Import in your layout
// quartz.layout.ts
import { Search } from "@quartz-community/search";
// Create the Search component once
const searchComponent = Search({
enablePreview: true,
placeholder: "Search for something",
title: "Search",
});
export const defaultContentPageLayout: PageLayout = {
// ... other layout config
left: [
searchComponent,
// ... other components
],
};
export const defaultListPageLayout: PageLayout = {
// ... other layout config
left: [
searchComponent, // Reuse the same component instance
// ... other components
],
};
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 from
/static/contentIndex.json - 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.
License
MIT