Giter VIP home page Giter VIP logo

eleventy-plugin-related's Introduction

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's People

Contributors

dependabot[bot] avatar jpoehnelt avatar lmammino avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

lmammino

eleventy-plugin-related's Issues

Should the top matches be paired?

Say I'm compare document A with documents A B C D and E; and document B is the most related. I would expect that comparing document B with A B C D and E would result in document A being the most related (I'm assuming the absolute match is somehow excluded). I'm not finding this to be the case. Is this to be expected?

Cannot read properties of undefined

This looks cool and I wanted to give it a try, but couldn't get it to work. I'm probably not using it correctly, perhaps the docs could be elaborated on a bit.

Using the example from the readme made 11ty throw a Cannot read properties of undefined (reading 'map') error. It seems to complain about any variable that happens to be in the template where the filter is used.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.