Skip to content

Instantly share code, notes, and snippets.

@ci-ryan-garcia
Created September 28, 2017 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ci-ryan-garcia/5e18d92c46c7f84f3d87b37dedbea78f to your computer and use it in GitHub Desktop.
Save ci-ryan-garcia/5e18d92c46c7f84f3d87b37dedbea78f to your computer and use it in GitHub Desktop.
Jekyll Plugin for Relative Links
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