summaryrefslogtreecommitdiffstats
path: root/blog
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2015-08-03 20:48:49 +0200
committerHarald Eilertsen <haraldei@anduin.net>2015-08-03 20:48:49 +0200
commit6cbf7887eafaa8c7be1a17b9325e40711502bcf1 (patch)
tree23b983f793ffcffdec88128026538cc5415245cf /blog
parentcbb2ccbddc8e232aedebf314b11ef69a049bfb10 (diff)
downloadnorsk-urskog-main-6cbf7887eafaa8c7be1a17b9325e40711502bcf1.tar.gz
norsk-urskog-main-6cbf7887eafaa8c7be1a17b9325e40711502bcf1.tar.bz2
norsk-urskog-main-6cbf7887eafaa8c7be1a17b9325e40711502bcf1.zip
Monkeypatch multiple language plugin.
It would generate incorrect URL's for blog posts. This should be fixed upstream sometime, but until we have the time we do it like this.
Diffstat (limited to 'blog')
-rw-r--r--blog/_plugins/jekyll_multiple_languages.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/blog/_plugins/jekyll_multiple_languages.rb b/blog/_plugins/jekyll_multiple_languages.rb
index 145526c..4b1afe8 100644
--- a/blog/_plugins/jekyll_multiple_languages.rb
+++ b/blog/_plugins/jekyll_multiple_languages.rb
@@ -1 +1,22 @@
require 'jekyll/multiple/languages/plugin'
+
+# Monkey patch a few functions in Jekyll#Post to make this work...
+# Should probably try to upstream this instead.
+#
+module Jekyll
+ class Post
+ alias url_orig url
+ def url
+ # Drop the _i18n prefix of the generated url
+ url_orig.gsub("_i18n/", '')
+ end
+
+ alias destination_orig destination
+ def destination(dest)
+ # Drop extra lang prefix if it occurs multiple times.
+ # For all but the default language it is defined both in the
+ # dest directory and the post url. That's one too many.
+ destination_orig(dest).sub(/#{site.config['lang']}\/#{site.config['lang']}/, "#{site.config['lang']}")
+ end
+ end
+end