Open rampatra opened 4 years ago
I think you can use Jekyll's where
filter for this..
Disclaimer: The following is untested.
{% assign question_category_posts = ... %}
{% assign ruby_question_category_posts = question_category_posts | where: "categories", "ruby" %}
Actually, I want to create a generic page to show posts belonging to two categories.
For example,
www.blog.com/category/question/ruby
then show posts belonging to category question
and ruby
.www.blog.com/category/question/java
then show posts belonging to category question
and java
.www.blog.com/category/scala
then show posts belonging to category scala
only.Is this possible with jekyll-archives
plugin or is there a better way?
If this feature isn't there in this plugin, it will be a good addition. We can add both and
and or
to combine different types.
Hi there,
Here is a workaround I figured out:
question/java
def categories
categories = Hash.new
@posts.each do |post|
cats = post.data["categories"]
cate = ""
cats.each do |cat|
cate = cate +"/"+ cat
end
post_arr = categories.fetch(cate, [])
post_arr.append(post)
categories.store(cate, post_arr)
end
return categories
# @site.categories
end
Modify slugify_string_title
to do the slugifying by ourselves so that /
will not be replaced with -
.
def slugify_string_title
return unless title.is_a?(String)
Utils.slugify(title, :mode => @config["slug_mode"]) # handle this
end
Can I list all posts on a page that belong to two categories, let's say,
question
andruby
? Right now I can list all posts either with categoryquestion
orruby
but not both.