Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Related posts #81

Closed
bhollis opened this issue Oct 1, 2012 · 9 comments
Closed

Related posts #81

bhollis opened this issue Oct 1, 2012 · 9 comments
Labels

Comments

@bhollis
Copy link
Contributor

bhollis commented Oct 1, 2012

We should provide a method on each blog article that returns "related articles" for that article. We can crib the algorithm for related posts from https://wordpress.org/extend/plugins/yet-another-related-posts-plugin/

@fs-railscasts
Copy link

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.

@LeonB
Copy link

LeonB commented Feb 13, 2013

Would be a nice feature!

@derekconjar
Copy link

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

@tdreyno
Copy link
Member

tdreyno commented Nov 15, 2013

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

@ngs
Copy link

ngs commented May 11, 2014

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

@bhollis
Copy link
Contributor Author

bhollis commented May 11, 2014

Cool!

@chrishough
Copy link

@ngs that extension is awesome. Well done! 😸

@tdreyno tdreyno closed this as completed Sep 9, 2014
@tdreyno
Copy link
Member

tdreyno commented Sep 9, 2014

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

@iwarner
Copy link
Contributor

iwarner commented Nov 17, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants