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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix author bug #2010

Merged
merged 3 commits into from
Nov 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,5 @@ DEPENDENCIES
RUBY VERSION
ruby 2.3.1p112

RUBY VERSION
ruby 2.3.1p112

BUNDLED WITH
1.13.5
16 changes: 14 additions & 2 deletions _plugins/author.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ def lookup(input, args)
end
end

# method to set the site_url given the Jekyll configurations
# works locally, on Federalist, and in production
def set_site_url
baseurl = Jekyll.sites[0].config['baseurl']
config_url = Jekyll.sites[0].config['url']
if baseurl.include? 'site/18F/18f.gsa.gov'
config_url
else
baseurl
end
end

# team_link filter
#
# A liquid filter that takes an author name as "input" and returns a link to an author's
Expand All @@ -109,9 +121,9 @@ def lookup(input, args)
def team_link(input)
authors = Jekyll.sites[0].collections['authors'].docs
index = authors.find_index { |x| x.data['name'] == input }
baseurl = Jekyll.sites[0].config['baseurl']
site_url = set_site_url
unless index.nil?
url = "#{baseurl}/author/#{authors[index].data['name']}"
url = "#{site_url}/author/#{authors[index].data['name']}"
full_name = authors[index].data['full_name']
string = "<a class='post-author' itemprop='name' href='#{url}'>#{full_name}</a>"
else
Expand Down