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

Quickest way to integrate a search bar in your Kirby project. Index your content with a Kirby CLI command or Panel button push it to Algolia. The Algolia's DocSearch JavaScript library will display a search button and result modal for you.

You can use the Algolia free plan, since the plugin itself indexes and parses the site. The Algolia crawler (a paid feature) is not needed. Leaving you with the option to stick with the free tier. πŸ’Έ

β€œBut DocSearch is for documentations! My Kirby project is not a documentation!” you might add.

Well, we co-opt the DocSearch library for our own purposes. 😏 The library can be used anywhere, if the data model matches the requirements. Which it does. πŸŽ‰

Key Features

Preview

Requirements

Kirby is not free software. However, you can try Kirby and the Starterkit on your local machine or on a test server as long as you need to make sure it is the right tool for your next project. … and when you’re convinced, buy your license.

Installation

Composer

Download

Download and copy this repository to /site/plugins/kirby-algolia-docsearch.

Setup

Algolia Account

If you do not yet have an Algolia account, you can create one.

DocSearch Library

The DocSearch library to display the search input field and result modal is not included in this package. Follow the instructions on the Algolia DocSearch installation website to add it to your project.

πŸ‘‰ tl;dr Installation 1. Import the required JS and CSS files in your project. Either by using a CDN or by installing the library via NPM. Or: 2. Create a [container](https://docsearch.algolia.com/docs/api#container) for your DocSearch component to go in. 3. Initialize the DocSearch library with your Algolia credentials.

Usage

Configuration

Callback for Content

Instead of extracting content by an HTML tag name, you can define a closure which returns the content of a page:

In multi-language projects, you can also pass the language code to the closure and return the content for the given language:

Defining callbacks for each template is also possible:

Indexing the Site

Kirby CLI

Run the algolia-docsearch:index command to index your content.

Panel Button

Given you have Janitor plugin installed, you can add a button to the Panel to index your content.

Page Hooks

This plugin registers page hooks to index a given page on changed slug, title, content or status. These hooks are not triggered by default, but have to be enabled in the plugin options.

With hooks enabled, you can index the whole page once and the plugin will keep the index up to date.

Multilang Projects

If languages are enabled in your Kirby project, the plugin will create an Algolia index for each language. The index name will be the value of the index option appended by the language code, e.g. example-de.

Cookbook

Index Blocks from text Field

If you only want to index the main content of your pages, e.g. in a blocks field, you can define a closure for the content option which returns the text content of a page.

DocSearch Initialization in Multilang Projects

For multilanguage projects you have to pass the translation's index name to the DocSearch library. You can extract the lang attribute from the html tag and append it to the index name.

Styling the Search Modal

The DocSearch library provides a customization API to style the search modal. You can add the following CSS to your project to style the search modal.

In practice, it's easiest to overwrite some CSS Custom Properties. You may take a look at how I styled the component.

Special Thanks

License

Johann Schopplich


All versions of kirby-algolia-docsearch with dependencies

PHP Build Version
Package Version
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 ....