Repository navigation
feat(flame): search provider plugins and @docubook/plugin-search-algolia - #476
Conversation
A plugin declares a search provider on docs pages with a #docubook-search-provider JSON block. Flame keeps its search bar, mobile search icon and Cmd/Ctrl K, imports the provider module on first use and opens its UI. With askAi: true it adds the Ask AI buttons and Cmd/Ctrl I. DevServerContext gains assetsPath so a plugin can serve the files it writes to BuildEndContext.assetsDir during flame dev.
Algolia DocSearch v5 keyword search in the DocSearch dialog, and Ask AI in the DocSearch Sidepanel, through flame's search provider contract. Options are validated when the build starts. The browser build is copied beside flame's bundles and served from the site's own origin. The package stays private until its first npm release. plugins/* joins the pnpm workspace, and the release-plan check ignores the 'none' entries that dependents of flame produce.
…nfig to flame's html The Algolia page now covers the plugin. The crawler config indexes the page description, body paragraphs, list items and table cells inside #mdx-content-island, so 'Last updated' and the footer stay out of the index and table cells become searchable. It strips the mdx-content-island anchor, drops main-navbar (no longer in the HTML) and sets renderJavaScript to false: flame writes every page as static HTML.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
ℹ️ No blocking issues. Two rough edges in the plugin's browser module are worth fixing before the first publish.
Reviewed changes
Mode: senior, because the PR touches plugin execution and the search UI on every docs page. I reviewed the whole PR: flame's new search provider contract, the Ask AI buttons in the sidebar, DevServerContext.assetsPath, the new @docubook/plugin-search-algolia package, the workspace and release-plan wiring, and the docs. Verdict: READY WITH MINOR FIXES. No P0 or P1 findings.
- Search provider contract.
search-provider.tsvalidates themodulepath before any import happens. It refuses absolute, remote,..and non-script paths. Failed imports are not cached, and load errors are logged instead of thrown. - Search and Sidebar UI.
SearchpicksProviderSearchwhen a provider is declared andBuiltinSearchotherwise. The sidebar island is always mounted withcreateRoot(client.ts), so readingdocumentinsideuseStatecannot cause a hydration mismatch. - Dev serving.
assetsPath: bundlePath()is set in bothserver.tsandserver.impl.ts. PluginhandleRequestruns before flame's static/assets/handler, so in dev the plugin serves its own files under the same URL the client builds. - Algolia plugin. Options are validated at load time.
appIdis restricted to an upper-case alphanumeric host label before it goes into the preconnect URL.serializeForScriptblocks</script>breakout. Dev file serving rejects encoded traversal. I checked the DocSearch 5.2.0 API this code relies on against the installed package:onReady,keyboardShortcutskeys,isOpen, the./docsearchsubpath, and both surfaces portaling tobody. All of it matches. - Workspace and release.
plugins/*joins the workspace.check-release-plan.mjsnow dropsnoneentries. The plugin stays private. - Docs. The Algolia guide is rewritten, the crawler config now matches flame's HTML, and
plugins.mdxgains a "Search providers" section.
Top priorities:
- Stop caching rejected DocSearch chunk imports in the client module.
- Version
style.csslikeclient.js.
Plugin tests pass locally (32/32).
claude-opus-5-5 | 𝕏
- A failed DocSearch or Sidepanel load is no longer cached: retryable() clears it so the next open retries, and the failure is logged instead of left as an unhandled rejection. - style.css carries the client module's ?v=<version> query, so an upgrade is not served the old theme from a long-lived bundle cache.
There was a problem hiding this comment.
✅ No new issues found. Both findings from the previous review are fixed, and their threads are resolved.
Reviewed changes
Mode: senior, re-review of 87469d9, which only touches the plugin's browser module and adds a test. Verdict: READY.
- Failed loads now retry.
loadModalandloadPanelgo through the newretryable()helper. It shares one in-flight setup between callers and forgets a rejected one, so the nextopen()oraskAi()loads again. This matches flame's own loader, which doesn't cache failures. The eager prefetch and both call sites end in.catch(logLoadError), so a failed load is logged rather than left as an unhandled rejection. - Stylesheet is versioned. The
<link>now takes its URL query fromimport.meta.url, sostyle.cssgets the same?v=<version>asclient.js. Long-lived bundle caches won't serve the old theme after an upgrade. - New client test.
client.test.tscoversretryabledirectly. It also checks that the provider logs a failed eager load, recovers on the nextopen(), and reuses the instance after that. I ran the plugin tests locally on87469d9: 35 of 35 pass.
claude-opus-5-5 | 𝕏

Summary
Flame can now hand its search dialog to a plugin. The first such plugin,
@docubook/plugin-search-algolia, lives in the newplugins/directory: Algolia DocSearch v5 keyword search, plus Ask AI in its own side panel.Search provider contract (
@docubook/flame, minor)<script type="application/json" id="docubook-search-provider">block, usually throughinjectHead. Itsmodulepath is relative to the bundle directory.⌘ K/Ctrl K. It imports the module the first time a reader hovers, focuses or opens search, and callsopen()from the module's default export.askAi: true, flame adds a Sparkles button beside the sidebar search bar, an Ask AI row in the mobile menu drawer, and⌘ I/Ctrl I. These callaskAi(), a surface separate from the search dialog.DevServerContextgainsassetsPath(/assets, or<basePath>/_flamewithexperimental.pages), so a plugin can serve the files it writes toBuildEndContext.assetsDirduringflame dev.SearchProvider,SearchProviderConfigandSearchProviderFactoryare exported from@docubook/flame.@docubook/plugin-search-algolia(private for now)appId,apiKey,indexName,askAi,searchParameters, …) are validated when the build starts. A bad value stops the build with a[plugin:search-algolia]error naming the option.script-src 'self'needs no change.relativeUrls(defaulttrue) opens results on the current site, so search also works inflame devand on preview deployments.plugins/*joins the pnpm workspace.scripts/check-release-plan.mjsnow ignoresnoneentries, which dependents of flame produce.Docs
search/algolia.mdxnow documents the plugin: install, where search and Ask AI appear, options, Ask AI, crawler setup and deploy.contentis.prose > p, #mdx-content-island p, #mdx-content-island li, #mdx-content-island td. "Last updated" and the "Made with DocuBook" footer were<p>elements inside.prose, so they were indexed on every page. They are now left out. Table cells (788<td>) were not indexed before and now are. Everything else the old selector caught is still caught.layoutAnchorsstripsmdx-content-island, the id of the MDX wrapper.main-navbaris no longer in the HTML, so it was removed.renderJavaScriptis nowfalse. All content is present in the static HTML, so the crawler needs no browser.plugins.mdxandsearch/built-in.mdxlink to the new plugin.Release plan
The changeset bumps
@docubook/flameby a minor version. The plugin staysprivatein this PR, for two reasons:workspace:^peer range would also accept flame 2.4.0, where it silently does nothing.changeset publishwould fail on it.After flame's release:
0.1.0and removeprivate.pnpm publish --access public. Use pnpm, not npm, so thatworkspace:^becomes^<flame version>.release.ymlon npmjs.com.Later releases go through Changesets.
Verification
tscandoxlintpass for both packages.scripts/check-release-plan.mjspasses all 6 scenarios.