summaryrefslogblamecommitdiffstats
path: root/blog/_plugins/jekyll_multiple_languages.rb
blob: 4b1afe828a41144464e8ceca3280c0b6c77cb983 (plain) (tree)
1
                                          




















                                                                                                            
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