Listing the last 10 posts from all blogs in a multiple blog setup

I have 4 different blogs and I want to list the last 10 most recent posts from all of them combined into one list.
To be clear, I don’t want 40 items in a list, I want 10 items total, but they are made up from the 4 blogs.
They should be listed in chronological order.

Any suggestions?
Should I move away from separate blogs and use one blog with categories instead to differentiate the 4 topic areas?

Thank you,
-Bryan

One approach could be to let each of your blog publish a ”page” with it’s ten latest blogposts. Make this page layoutless, and format it as yaml or json.

There are several options for making them available, but you could for example use after_build to move them from the build directory into the data directory of the blog that are to publish the ‘latest ten’-list.

Then read these four pages as data and combine them to one data set. Sort, and select the latest ten.

Hi Bryan, I did something simalair on zadevchat.io, but just in the feed. Still need to do it on the website itself, but it should work the same.

  # Get all the articles for the blogs
  episodes = blog('podcast').articles
  articles = blog('blog').articles
  # Make a combined list of the 5 newest entries, sorted by date
  combined = [ episodes[0..5], articles[0..5] ].flatten.compact.sort_by(&:date).reverse

  # Iterate over the 5 latest articles in the combined list
  combined[0..5].each do |article|
  end

HTH