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

Add support custom title for collections #341

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/jekyll-feed/feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

{% assign title = site.title | default: site.name %}
{% if page.collection != "posts" %}
{% assign collection = page.collection | capitalize %}
{% assign collection = page.title | default: page.collection | capitalize %}
{% assign title = title | append: " | " | append: collection %}
{% endif %}
{% if page.category %}
Expand Down
10 changes: 7 additions & 3 deletions lib/jekyll-feed/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def generate(site)
path = feed_path(:collection => name, :category => category)
next if file_exists?(path)

@site.pages << make_page(path, :collection => name, :category => category)
@site.pages << make_page(path, :title => meta["title"], :collection => name, :category => category)
end
end
generate_feed_by_tag if config["tags"] && !@site.tags.empty?
Expand Down Expand Up @@ -67,7 +67,10 @@ def collections
{}
end

@collections = normalize_posts_meta(@collections)
if config["posts"] != false
@collections = normalize_posts_meta(@collections)
end

@collections.each_value do |meta|
meta["categories"] = (meta["categories"] || []).to_set
end
Expand Down Expand Up @@ -117,13 +120,14 @@ def file_exists?(file_path)

# Generates contents for a file

def make_page(file_path, collection: "posts", category: nil, tags: nil)
def make_page(file_path, title: nil, collection: "posts", category: nil, tags: nil)
PageWithoutAFile.new(@site, __dir__, "", file_path).tap do |file|
file.content = feed_template
file.data.merge!(
"layout" => nil,
"sitemap" => false,
"xsl" => file_exists?("feed.xslt.xml"),
"title" => title,
"collection" => collection,
"category" => category,
"tags" => tags
Expand Down