Sha256: 1686c64f6a748d9903bd4b408df7655def0848f6d671215f4764e88d53927517

Contents?: true

Size: 696 Bytes

Versions: 7

Compression:

Stored size: 696 Bytes

Contents

# frozen_string_literal: true

# We keep a global variable with the site in it because we can't access
# it from the cleanup hook.
$site = nil

# Only run on the default locale since it's going to be in the root
# destination
Jekyll::Hooks.register :site, :post_render do |site|
  next unless site.locales?
  next unless site.default_locale?

  $site = site
end

# Keep files in other locales since they're not generated by the default
# locale.
Jekyll::Hooks.register :clean, :on_obsolete do |obsolete|
  next if $site.nil?

  $site.locales.each do |locale|
    next if locale == $site.locale

    obsolete.delete_if do |x|
      x.sub($site.dest + '/', '').start_with? locale
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
jekyll-locales-0.2.1 lib/jekyll/locales/hooks/cleanup.rb
jekyll-locales-0.2.0 lib/jekyll/locales/hooks/cleanup.rb
jekyll-locales-0.1.14 lib/jekyll/locales/hooks/cleanup.rb
jekyll-locales-0.1.13 lib/jekyll/locales/hooks/cleanup.rb
jekyll-locales-0.1.12 lib/jekyll/locales/hooks/cleanup.rb
jekyll-locales-0.1.11 lib/jekyll/locales/hooks/cleanup.rb
jekyll-locales-0.1.10 lib/jekyll/locales/hooks/cleanup.rb