Configuration Reference
Complete reference for all configuration options, API methods, and customization capabilities of Reef Search.
Script Tag Attributes
Configure Reef Search by adding data attributes to the script tag:
| Attribute | Type | Default | Description |
|---|---|---|---|
data-sitemap |
string |
/sitemap.xml |
Path to your sitemap.xml file. Can be relative (sitemap.xml) or absolute (/sitemap.xml) |
data-max-pages |
number |
500 |
Maximum number of pages to index. Increase for larger sites, decrease for performance. |
data-scope |
string |
auto |
CSS selector for the main content area. Limits indexing to within this element. |
data-index-actions |
boolean |
true |
Whether to index clickable elements (buttons, toggles) as searchable actions. |
data-index-media |
boolean |
true |
Whether to index images (via alt text) and media with transcripts. |
data-index-structured-data |
boolean |
true |
Whether to extract and index FAQ entries from JSON-LD structured data. |
data-index-hidden |
boolean |
true |
Whether to include hidden/collapsed content in the index. |
data-file-extensions |
string |
pdf,doc,docx,xls,xlsx,ppt,pptx,zip,csv |
Comma-separated list of file extensions to classify as downloadable files. |
data-exclude-action |
string |
(none) |
CSS selector for elements to exclude from action indexing. |
data-actions-mode |
'execute' | 'navigate-only' |
execute |
Controls action execution behavior. 'navigate-only' disables auto-click execution. |
Complete Example
<script
src="/reef.min.js"
data-sitemap="/sitemap.xml"
data-max-pages="1000"
data-scope="main"
data-index-actions="true"
data-index-media="true"
data-index-structured-data="true"
data-index-hidden="true"
data-actions-mode="execute"
></script>
Detailed Configuration
data-sitemap
The sitemap URL is the primary discovery mechanism for Reef Search. The crawler fetches this file on initialization.
// Default: looks for /sitemap.xml
<script src="reef.min.js"></script>
// Custom path (relative to current page)
<script src="reef.min.js" data-sitemap="sitemap-index.xml"></script>
// Absolute path
<script src="reef.min.js" data-sitemap="/docs/sitemap.xml"></script>
data-max-pages
Controls how many pages Reef Search will index. This limit prevents:
- Excessive memory usage on large sites
- Long indexing times that block the main thread
- Bandwidth exhaustion on sites with many pages
// Index only the first 100 pages
<script src="reef.min.js" data-max-pages="100"></script>
Recommended values based on site size:
| Site Size | Recommended max-pages |
|---|---|
| Small docs (< 50 pages) | 50-100 |
| Medium docs (50-500 pages) | 500 (default) |
| Large docs (> 500 pages) | 1000 or higher |
data-scope
Limit indexing to a specific content area using a CSS selector. This is useful for excluding:
- Navigation menus
- Footer content
- Sidebar widgets
- Repeated elements across pages
// Only index content inside <main>
<script src="reef.min.js" data-scope="main"></script>
// Index content inside element with specific class
<script src="reef.min.js" data-scope=".content-area"></script>
// Index inside the main element or article fallback
<script src="reef.min.js" data-scope="main, article"></script>
data-actions-mode
Controls how action-type search results are handled:
| Value | Behavior |
|---|---|
execute (default) |
Same-page actions execute immediately; cross-page actions navigate with deferred execution |
navigate-only |
All actions navigate to the page without automatic execution |
// Disable action execution entirely (safer for dynamic sites)
<script src="reef.min.js" data-actions-mode="navigate-only"></script>
JavaScript API
Access the Global Reef Object
After initialization, Reef Search attaches to window.Reef:
// Access the Reef Search instance
const reef = window.Reef;
// Open the search modal programmatically
reef.open();
// Close the search modal
reef.close();
API Methods
| Method | Description |
|---|---|
open() |
Opens the search modal and focuses the input field. Triggers reindexing if not yet complete. |
close() |
Closes the search modal and resets the query. |
reindex() |
Rebuilds the search index. Useful after dynamic content loads. |
onselect(callback) |
Registers a callback function that fires when a result is selected. |
onSelect Callback
Hook into search result selection for analytics or custom behavior:
window.Reef.onselect((result, event) => {
console.log('Selected:', result.headingText, result.url);
// Custom analytics tracking
gtag('event', 'search_select', {
search_term: result.headingText,
target_url: result.url
});
});
Programmatic Usage
Create a custom trigger button or integrate with existing UI:
// Custom trigger button
document.getElementById('searchButton').addEventListener('click', () => {
window.Reef.open();
});
// Search with initial query
window.Reef.open();
setTimeout(() => {
const input = document.querySelector('reef-host input');
if (input) input.value = 'search terms';
input.dispatchEvent(new Event('input'));
}, 100);
Theming
Built-in Themes
Reef Search uses a dark theme by default. The modal UI is styled via Shadow DOM for style isolation.
Custom Styling
While Shadow DOM prevents external styling, you can configure key visual properties via CSS custom properties (planned for future versions). Currently, the UI uses these internal styles:
/* Modal colors (defined in Shadow DOM) */
:host { background: rgba(5, 5, 6, 0.65); }
.panel { background: #131316; border: 1px solid #2a2a2e; }
.input { color: #edebe6; }
.result:hover { background: rgba(108, 140, 255, 0.14); }
.result mark { background: rgba(255, 214, 102, 0.22); }
Hotkeys
The default hotkey configuration:
| Key Combination | Action |
|---|---|
| ⌘K / Ctrl+K | Open search modal |
| ↑ / ↓ | Navigate results |
| Enter | Select highlighted result |
| Esc | Close search modal |
Configuration Examples
Minimal Setup
<script src="reef.min.js"></script>
Large Documentation Site
<script
src="reef.min.js"
data-sitemap="/sitemap.xml"
data-max-pages="1000"
data-scope="article, main"
data-index-actions="true"
data-index-media="true">
</script>
Blog with Hidden Content
<script
src="reef.min.js"
data-sitemap="/sitemap.xml"
data-max-pages="200"
data-index-hidden="false" // Exclude collapsed content
data-actions-mode="navigate-only">
</script>
Dashboard Application
<script
src="reef.min.js"
data-sitemap="/sitemap.xml"
data-max-pages="100"
data-index-actions="true"
data-index-media="false"
data-actions-mode="execute">
</script>