aboutsummaryrefslogtreecommitdiff
path: root/_plugins
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2018-02-28 00:24:24 +0100
committerNoah Loomans <noahloomans@gmail.com>2018-02-28 00:24:24 +0100
commit0a22ac3452d6fc25ea0b422188d20991a5b2da58 (patch)
treebc9fcc7a043aee81dd4266e8a4469a551c3081e7 /_plugins
parent1d000946313c5758b2935ed8cc9a64858172ff74 (diff)
Fix all links and advertize IPFS version
Diffstat (limited to '_plugins')
-rw-r--r--_plugins/relativize_url.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/_plugins/relativize_url.rb b/_plugins/relativize_url.rb
new file mode 100644
index 0000000..23e1712
--- /dev/null
+++ b/_plugins/relativize_url.rb
@@ -0,0 +1,34 @@
+require 'pathname'
+
+module Jekyll
+ module UrlRelativizer
+ # def relativize_url(url)
+ # pageUrl = @context.registers[:page]["url"]
+ # if pageUrl[-1] == "/"
+ # pageDir = Pathname(pageUrl)
+ # else
+ # pageDir = Pathname(pageUrl).parent
+ # end
+ # ret = Pathname(url).relative_path_from(pageDir).to_s
+ # puts pageDir.to_s + + " -> " + url.to_s + " => " + ret
+ # ret
+ # end
+
+ def relativize_url(input)
+ return if input.nil?
+ input = ensure_leading_slash(input)
+ page_url = @context.registers[:page]["url"]
+ if page_url[-1]
+ page_dir = Pathname(page_url)
+ else
+ page_dir = Pathname(page_url).parent
+ end
+
+ ret = Pathname(input).relative_path_from(page_dir).to_s
+ # puts page_url.to_s + "," + page_dir.to_s + + "," + input.to_s + "," + ret
+ return ret
+ end
+ end
+end
+
+Liquid::Template.register_filter(Jekyll::UrlRelativizer)