diff --git a/40-PicoSearch.php b/40-PicoSearch.php index 9ba752a..7360ca3 100644 --- a/40-PicoSearch.php +++ b/40-PicoSearch.php @@ -59,6 +59,14 @@ class PicoSearch extends AbstractPicoPlugin }); } + $pico = $this->getPico(); + $excludes = $pico->getConfig('search_excludes'); + if (!empty($excludes)) { + foreach ($excludes as $exclude_path) { + unset($pages[$exclude_path]); + } + } + if (isset($this->search_terms)) { $pages = array_filter($pages, function ($page) { return (stripos($page['title'], $this->search_terms) !== false) diff --git a/README.md b/README.md index 426f1a7..f7f2e79 100644 --- a/README.md +++ b/README.md @@ -57,4 +57,13 @@ template file or on a specific page. e.preventDefault(); }); -``` \ No newline at end of file +``` + +## Configuration options + +You can exclude certain pages from being included in the search results by using the configuration option `search_excludes`. +Set it to an array of pages you'd like to exclude, where each page is specified as its path relative to the content root: + +``` +$config['search_excludes'] = ['search', 'some/other/page']; +```