<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
johannschopplich / kirby-algolia-docsearch example snippets
# /site/config/config.php
return [
'johannschopplich.algolia-docsearch' => [
// Algolia App ID for the project
'appId' => 'ALGOLIA_APP_ID',
// Algolia API Key for the project
'apiKey' => 'ALGOLIA_API_KEY',
// Algolia index base name; in mutlilang projects,
// the language code will be appended by the plugin,
// e.g. `example-de` for German
'index' => 'example',
// HTML tag name which contains a page's content or
// closure which returns the content of a page
// If not given defaults to `body`
'content' => 'main',
// Register hooks to index a page on changed slug,
// title, content or status
'hooks' => false,
// Templates which should be indexed
'templates' => [
'article',
'default',
'home',
'project'
],
// Optional pages which should be excluded from the index
'exclude' => [
'pages' => [
'blog/some-post',
]
],
// Define the search hit label
'label' => [
// Accepts a string or an array of strings for each language
// Single language:
// 'default' => 'Page'
// Multiple languages:
'default' => [
'de' => 'Seite',
'en' => 'Page'
],
'templates' => [
// Accepts a string or an array of strings for each language
// Single language:
// 'article' => 'Article'
// Multiple languages:
'article' => [
'de' => 'Artikel',
'en' => 'Article'
],
'project' => [
'de' => 'Projekt',
'en' => 'Project'
]
]
]
]
];
# /site/config/config.php
return [
'johannschopplich.algolia-docsearch' => [
// Return any string which should be indexed
'content' => fn (\Kirby\Cms\Page $page, string|null $languageCode) => strip_tags($page->text()->toBlocks()->toHtml())
// other options …
]
];
# /site/config/config.php
return [
'johannschopplich.algolia-docsearch' => [
// Return any string which should be indexed
'content' => function (\Kirby\Cms\Page $page, string|null $languageCode) {
return strip_tags($page->content($languageCode)->text()->toBlocks()->toHtml());
}
// other options …
]
];
# /site/config/config.php
return [
'johannschopplich.algolia-docsearch' => [
// Return any string which should be indexed
'content' => [
'default' => fn (\Kirby\Cms\Page $page, string|null $languageCode) => strip_tags($page->text()->toBlocks()->toHtml())
'home' => fn (\Kirby\Cms\Page $page, string|null $languageCode) => $page->description()->value()
]
// other options …
]
];