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

Allow to get archive category title from a data file for SEO. #167

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
22 changes: 21 additions & 1 deletion lib/jekyll-archives/archive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Jekyll
module Archives
class Archive < Jekyll::Page
attr_accessor :posts, :type, :slug
attr_accessor :posts, :type, :slug, :show_date, :show_author

# Attributes for Liquid templates
ATTRIBUTES_FOR_LIQUID = %w(
Expand All @@ -15,6 +15,8 @@ class Archive < Jekyll::Page
path
url
permalink
show_date
show_author
).freeze

# Initialize a new Archive page
Expand All @@ -31,6 +33,8 @@ def initialize(site, title, type, posts)
@title = title
@config = site.config["jekyll-archives"]
@slug = slugify_string_title
@show_author = true
@show_date = true

# Use ".html" for file extension and url for path
@ext = File.extname(relative_path)
Expand All @@ -41,6 +45,22 @@ def initialize(site, title, type, posts)
"layout" => layout,
}
@content = ""

if type == "category"
if @config["categories_data_file"] && @site.data[@config["categories_data_file"]] && @site.data[@config["categories_data_file"]][title]
@categoryData = @site.data[@config["categories_data_file"]][title]
if !@categoryData["archive_title"].nil?
@title = @categoryData["archive_title"]
elsif !@categoryData["name"].nil?
@title = @categoryData["name"]
end

@show_author = @categoryData["show_author"] unless @categoryData["show_author"].nil?
@show_date = @categoryData["show_date"] unless @categoryData["show_date"].nil?

end
end

end

# The template of the permalink.
Expand Down