Download the PHP package johannschopplich/kirby-algolia-docsearch without Composer

On this page you can find all versions of the php package johannschopplich/kirby-algolia-docsearch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package kirby-algolia-docsearch

# Kirby Algolia DocSearch Kirby Algolia DocSearch is a plugin for [Kirby CMS](https://getkirby.com) that indexes your pages into Algolia for the [DocSearch](https://docsearch.algolia.com) search modal. It builds the records itself, so you don't need Algolia's paid crawler. [Features](#features) • [DocSearch Setup](#docsearch-setup) • [Options](#options) • [Limits](#limits)

When to Use

I want to… Use
Index the whole site kirby algolia-docsearch:index
Index the site from the Panel Janitor field with algolia-docsearch:index
Update the index when a page changes hooks option
Index unlisted pages, too filter option
Index a field instead of the rendered HTML content closure
Add data to each search hit attributes option
Tune Algolia's index settings indexSettings option
Index from my own code algolia()->index()

Features

🔦 Indexing Without the Crawler

The plugin renders every listed page of the configured templates, extracts the text of one HTML tag, and writes one DocSearch record per page. Run the Kirby CLI command to replace the index with the current state of the site:

On the command line, set Kirby's url option first, or the records get root-relative URLs such as /docs/installation.

With Janitor installed, the same command runs from a button in the Panel:

🔁 Page Hooks

With the hooks option enabled, a change to a page updates its record. Index the site once, and the hooks take over from there:

A page that shows content from elsewhere – a menu, a list of child pages, a site field, a file – keeps its old record until the next full index.

A hook that fails shows an Algolia error in the Panel. The page change is saved by then, and the next full index corrects its record.

The hooks stay off while Kirby's debug option is on.

🌐 One Index per Language

On a multi-language site, each language gets its own index: the index option plus the language code, e.g. example-en and example-de. Labels take one string per language:

🧩 Content From HTML or a Closure

By default, a record's content is the text inside the rendered page's <body>. Point the content option to another tag, such as main, or return the text from a closure. This one indexes a blocks field instead of the rendered page:

The closure receives the language code of the index it writes to. For different content per template, pass an array of closures keyed by template name, with default for the rest.

🛠️ Indexing From Your Own Code

In a route, a hook, or a script of your own, the algolia() helper returns the plugin's indexer:

indexPage() removes the record of a page that no longer belongs in the index, such as a draft or one the filter rejects. On a single-language site, call indexPage($page) without a language code.

Requirements

Installation

Composer (Recommended)

Manual Installation

Download a release and extract it to /site/plugins/kirby-algolia-docsearch.

DocSearch Setup

The plugin only fills the index. The search button and modal come from the DocSearch library, which you add to your frontend:

The @docsearch/js/docsearch entry is keyword search only. Use your Algolia Search API key here, never the key from the plugin options. On a multi-language site, pick the index of the current language, e.g. from the lang attribute of your <html> element:

See the DocSearch documentation for the CDN build and styling.

Options

All options are namespaced under johannschopplich.algolia-docsearch:

Option Default Description
appId – Algolia application ID. Required.
apiKey – Algolia API key with write access, such as the Admin API key. It stays on the server. Required.
index – Index name. Multi-language sites get one index per language, suffixed with the language code. Required.
templates [] Templates to index. Pages of other templates are left out, so nothing is indexed until you set this.
filter listed pages Closure fn (Page $page): bool that decides which pages of those templates get indexed. Drafts never are.
exclude.pages [] Page IDs to leave out, as case-insensitive regular expressions matched against the whole ID, e.g. blog/.*.
content body HTML tag whose text becomes the record's content, a closure fn (Page $page, string\|null $languageCode): string, or an array of closures per template with a default key.
label.default – Hit label (DocSearch's hierarchy.lvl0) as a string or an array per language code. Required unless label.templates covers every template.
label.templates [] Labels per template, in the same shapes as label.default.
attributes [] Extra record fields as closures fn (Page $page, string\|null $languageCode), keyed by field name.
searchableAttributes [] Attributes appended to DocSearch's searchable attributes.
indexSettings [] Algolia index settings. Each key replaces the plugin's default for that setting, including what searchableAttributes and attributes add to it.
hooks false Update the index when a page changes. See Page Hooks.

Example config.php:

Limits

Credits

License

Johann Schopplich


All versions of kirby-algolia-docsearch with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
getkirby/composer-installer Version ^1
algolia/algoliasearch-client-php Version ^3.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package johannschopplich/kirby-algolia-docsearch contains the following files

Loading the files please wait ...