Created
July 5, 2020 16:11
-
-
Save pzp1997/ed9860890d929f4f82455a1972795bd1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module LinkFilter | |
def gen_link(link) | |
if link.start_with?('http://', 'https://', '#') | |
link | |
elsif link.start_with?('site.data.links.') | |
desired_link = link.slice('site.data.links.'.length, link.length) | |
@context.registers[:site].data['links'][desired_link] | |
else | |
baseurl = @context.registers[:site].baseurl | |
jekyll_link = Jekyll::Tags::Link.send( | |
:new, | |
Jekyll::Tags::Link.tag_name, | |
link, | |
Liquid::ParseContext.new | |
).render(@context) | |
"#{baseurl}#{jekyll_link}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment