lapis / search
Site search for Lapis CMS: a search page and an x-search component over the published pages
Requires
- php: ^8.5
- lapis/cms: ^1.0
Requires (Dev)
- carthage-software/mago: ^1.62
- pestphp/pest: ^5.3
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Site search for Lapis CMS: a /search page, and an <x-search /> component for your own.
composer require lapis/search
/search works at once. To show it in the site's layout, make your own pages/search.php, which replaces the plugin's:
<x-layout title="Search"> <h1>Search</h1> <x-search /> </x-layout>
<x-search /> is a form (?q=) and the results of the page it is on, so it goes into a layout's header too, with the results on that page.
What is searched
The published page records that a search engine may list, the same as the sitemap's: no drafts, no noindex pages, none behind sign-in. In them, the title, the description and the published blocks (text, rich text without its tags, link labels, image alt texts, plugin blocks' text). Every word of the query must match; a match in the title counts most, then the description.
Not searched: global blocks (they are on every page), drafts, data tables, and file pages nobody edited (they have no record).
Each result is ['url' => …, 'title' => …, 'snippet' => …], where the snippet is escaped HTML with the matches in <mark>. From PHP: \Tempest\Container\get(\Lapis\Search\Search::class)->search('bread', limit: 10).
Accents count: kave does not find kávé. The texts are under search.* (English and Hungarian included); a site changes them in its own app/localization.<locale>.yml.
The search reads the pages on every query, which is fast for a few hundred pages. A site with thousands needs an index, which this version does not build.