https://github.com/jpoehnelt/eleventy-plugin-related
Plugin for related posts in Eleventy.
https://github.com/jpoehnelt/eleventy-plugin-related
eleventy eleventy-plugin natural nlp tf-idf
Last synced: 8 months ago
JSON representation
Plugin for related posts in Eleventy.
- Host: GitHub
- URL: https://github.com/jpoehnelt/eleventy-plugin-related
- Owner: jpoehnelt
- License: apache-2.0
- Created: 2022-04-14T04:21:11.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-01T17:02:44.000Z (over 2 years ago)
- Last Synced: 2025-01-31T04:51:16.636Z (9 months ago)
- Topics: eleventy, eleventy-plugin, natural, nlp, tf-idf
- Language: TypeScript
- Homepage: https://eleventy-plugin-related.netlify.app
- Size: 878 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# eleventy-plugin-related
[](https://www.npmjs.com/package/eleventy-plugin-related)


[](https://jpoehnelt.github.io/eleventy-plugin-related/)## Description
Filter and/or short code to rank text documents by similarity.
## Install
Install using NPM or similar.
```sh
npm i eleventy-plugin-related
```## Usage
```js
eleventyConfig.addFilter(
"related",
require("eleventy-plugin-related").related({
serializer: (doc) => [doc.title, doc.link ?? "", doc.text ?? ""],
weights: [10, 1, 3],
})
);
```Usage in a NunJucks template would look similar to the following.
```html
Related
- {{ result.relative }} - {{ result.document.title }}
{% for result in story | related(stories) %}
{% endfor %}
```
For more complex options, check out the package [related-documents](https://www.npmjs.com/package/related-documents), on which this package is based.