├── .gitignore ├── LICENSE ├── README.md ├── layouts ├── _default │ └── index.json.json └── partials │ └── json │ └── createindex.json └── theme.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | **/.DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Platform.sh 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hugo-meilisearch 2 | 3 | ## About 4 | 5 | This is not a standalone theme. It is a [Hugo](https://gohugo.io) theme component providing a the generation of a search index suitable for indexing with the awesome [MeiliSearch](https://www.meilisearch.com/). An open source, blazingly fast and hyper relevant search-engine that will improve your search experience. 6 | 7 | ## Usage 8 | 9 | 1. Add the `hugo-meilisearch` as a submodule to be able to get upstream changes later `git submodule add https://github.com/platformsh/hugo-meilisearch themes/hugo-meilisearch` 10 | 2. Add `hugo-meilisearch` as the left-most element of the `theme` list variable in your site's or theme's configuration file `config.yaml` or `config.toml`. Example, with `config.yaml`: 11 | ```yaml 12 | theme: ["hugo-meilisearch", "my-theme"] 13 | ``` 14 | or, with `config.toml`, 15 | ```toml 16 | theme = ["hugo-meilisearch", "my-theme"] 17 | ``` 18 | 19 | ### Credits 20 | 21 | Copyright © 2020 onwards, Chad Carlson, Nick Andregg, Ori Pekelman @platform.sh 22 | 23 | Thanks to 24 | - [Nicolas Martignoni](https://github.com/martignoni) for the approach I am borrowing -------------------------------------------------------------------------------- /layouts/_default/index.json.json: -------------------------------------------------------------------------------- 1 | {{- $numPages := len .Site.Pages -}}{{- $count := 0 -}}[{{- range .Site.Pages -}}{{- chomp ( partial "json/createindex.json" . ) -}}{{- $count = add $count 1 -}}{{- if ne $count $numPages -}},{{- end -}}{{- end -}}] 2 | -------------------------------------------------------------------------------- /layouts/partials/json/createindex.json: -------------------------------------------------------------------------------- 1 | 2 | {{- $tempURL := index ( split .RelPermalink "." ) 0 -}} 3 | 4 | {{- $url := "/" -}} 5 | {{- if ne $tempURL "/index" -}} 6 | {{- $url = printf "%s.html" $tempURL -}} 7 | {{- end -}} 8 | 9 | {{- $contentSplitPTAG := ( split .Content "p>" ) -}} 10 | {{- $text := index ( split ( index $contentSplitPTAG 1) "