relative_path filter

This commit is contained in:
2022-12-15 14:39:17 -05:00
parent aa0a8e624b
commit 2500f1a626
9 changed files with 87 additions and 29 deletions

10
_plugins/relative_path.rb Normal file
View File

@@ -0,0 +1,10 @@
module Jekyll
module RelativePath
def relative_path(url)
page_url = @context.registers[:page]['url']
Pathname(url).relative_path_from(Pathname(page_url)).to_s
end
end
end
Liquid::Template.register_filter(Jekyll::RelativePath)