eleventy-plugin-related
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

eleventy-plugin-related

npm Build Release Docs

Description

Filter and/or short code to rank text documents by similarity.

Install

Install using NPM or similar.

npm i eleventy-plugin-related

Usage

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.

<h3>Related</h3>
<ul>
  {% for result in story | related(stories) %}
  <li>{{ result.relative }} - {{ result.document.title }}</li>
  {% endfor %}
</ul>

For more complex options, check out the package related-documents, on which this package is based.

/eleventy-plugin-related/

    Package Sidebar

    Install

    npm i eleventy-plugin-related

    Weekly Downloads

    24

    Version

    1.0.6

    License

    Apache-2.0

    Unpacked Size

    24.8 kB

    Total Files

    10

    Last publish

    Collaborators

    • jpoehnelt