Created
September 28, 2017 21:54
-
-
Save ci-ryan-garcia/5e18d92c46c7f84f3d87b37dedbea78f to your computer and use it in GitHub Desktop.
Jekyll Plugin for Relative Links
This file contains 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
class Jekyll::Page | |
def relative | |
("../" * (url.split("/").length-1))[1...-1] | |
end | |
def to_liquid(attrs = ATTRIBUTES_FOR_LIQUID) | |
super(attrs + %w[ | |
relative | |
]) | |
end | |
end | |
class Jekyll::Post | |
def relative | |
("../" * (url.split("/").length-1))[1...-1] | |
end | |
def to_liquid(attrs = ATTRIBUTES_FOR_LIQUID) | |
super(attrs + %w[ | |
relative | |
]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment