Giter VIP home page Giter VIP logo

Comments (9)

ngs avatar ngs commented on July 27, 2024 1

Released an extension http://ngs.io/2014/05/11/middleman-blog-similar/

from middleman-blog.

fs-railscasts avatar fs-railscasts commented on July 27, 2024

I currently use this short method

  def related(page)
    all_pages = blog.tags.slice(*page.tags).values.first
    return [] if all_pages.blank?

    all_pages.delete_if { |p| p == page }
  end

  related(current_page)

It will return articles collection tied with current page by tags.

from middleman-blog.

LeonB avatar LeonB commented on July 27, 2024

Would be a nice feature!

from middleman-blog.

derekconjar avatar derekconjar commented on July 27, 2024

I haven't played around with this, but one solution could be to calculate the Levenshtein distance between the page content (yield) and each of the posts' content (page_articles.each). In other words, find out how different each of the article strings are from the current article.

The articles with the lowest Levenshtein distance are the related posts.

Here are two Ruby-based algorithm implementations:

http://en.wikibooks.org/wiki/Algorithm_implementation/Strings/Levenshtein_distance#Ruby

from middleman-blog.

tdreyno avatar tdreyno commented on July 27, 2024

@dconjar Looks interesting. We should definitely make the implementation pluggable though. Maybe allow other extensions to handle the details

from middleman-blog.

bhollis avatar bhollis commented on July 27, 2024

Cool!

from middleman-blog.

chrishough avatar chrishough commented on July 27, 2024

@ngs that extension is awesome. Well done! 😸

from middleman-blog.

tdreyno avatar tdreyno commented on July 27, 2024

@ngs Using it myself on a new project. So cool!

from middleman-blog.

iwarner avatar iwarner commented on July 27, 2024

@tdreyno Can you share that project link please - interested to see the outcome in real life thanks @ngs awesome job.

from middleman-blog.

Related Issues (20)

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.