summaryrefslogtreecommitdiffstats
path: root/blog/_plugins
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2015-08-24 20:48:35 +0200
committerHarald Eilertsen <haraldei@anduin.net>2015-08-24 20:48:35 +0200
commitea47219a2894d4fb304ae35e66b56e5e0e6e3827 (patch)
tree0e0855574748d34bcf811f38442b6998d393ae12 /blog/_plugins
parent56eeb72ac5b71e70d2e14ae7b2fe620ab5e43441 (diff)
downloadnorsk-urskog-main-ea47219a2894d4fb304ae35e66b56e5e0e6e3827.tar.gz
norsk-urskog-main-ea47219a2894d4fb304ae35e66b56e5e0e6e3827.tar.bz2
norsk-urskog-main-ea47219a2894d4fb304ae35e66b56e5e0e6e3827.zip
Add new tag page_title to retreive translated page title if available.
If no translation exist, use default translation, and if no default translation, use the key unmodified. This makes the titles for posts work as expected.
Diffstat (limited to 'blog/_plugins')
-rw-r--r--blog/_plugins/page_title.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/blog/_plugins/page_title.rb b/blog/_plugins/page_title.rb
new file mode 100644
index 0000000..039e859
--- /dev/null
+++ b/blog/_plugins/page_title.rb
@@ -0,0 +1,21 @@
+require "jekyll/multiple/languages/plugin"
+require "facets/kernel/silence"
+
+module Jekyll
+ class PageTitleTag < Liquid::Tag
+ def initialize(tag_name, text, tokens)
+ super
+ @key = text
+ end
+
+ def render(context)
+ text = silently do
+ t = Jekyll::LocalizeTag.new('t', @key, '')
+ t.render(context)
+ end
+ text || context[@key]
+ end
+ end
+end
+
+Liquid::Template.register_tag('page_title', Jekyll::PageTitleTag)