PHP code example of johannschopplich / kirby-algolia-docsearch
1. Go to this page and download the library: Download johannschopplich/kirby-algolia-docsearch library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
johannschopplich / kirby-algolia-docsearch example snippets
'label' => [
'default' => [
'en' => 'Page',
'de' => 'Seite'
]
]
'content' => fn (\Kirby\Cms\Page $page, string|null $languageCode) => strip_tags($page->content($languageCode)->get('text')->toBlocks()->toHtml())
// Replaces the index of every language, as the command does.
algolia()->index();
// Saves a page to one language's index.
algolia()->indexPage($page, 'en');
// Removes a page from every language's index.
algolia()->deletePage($page);
return [
'johannschopplich.algolia-docsearch' => [
'appId' => 'ALGOLIA_APP_ID',
'apiKey' => 'ALGOLIA_ADMIN_API_KEY',
'index' => 'example',
'templates' => ['default', 'article', 'project'],
'filter' => fn (\Kirby\Cms\Page $page) => $page->isListed() || $page->isUnlisted(),
'exclude' => [
'pages' => ['blog/drafts-.*']
],
'content' => 'main',
'label' => [
'default' => 'Page',
'templates' => [
'article' => 'Article',
'project' => 'Project'
]
],
'indexSettings' => [
'ranking' => ['words', 'typo', 'attribute', 'proximity', 'exact', 'custom']
],
'hooks' => true
]
];