Sha256: fabb13ff88b720fa611788895b81f24f9f4c9452185fa99df0c6e0ec7b1e3b8a

Contents?: true

Size: 799 Bytes

Versions: 4

Compression:

Stored size: 799 Bytes

Contents

# frozen_string_literal: true

module JekyllRedirectFrom
  # Module which can be mixed in to documents (and pages) to provide
  # redirect_to and redirect_from helpers
  module Redirectable
    # Returns a string representing the relative path or URL
    # to which the document should be redirected
    def redirect_to
      if to_liquid["redirect_to"].is_a?(Array)
        to_liquid["redirect_to"].compact.first
      else
        to_liquid["redirect_to"]
      end
    end

    # Returns an array representing the relative paths to other
    # documents which should be redirected to this document
    def redirect_from
      if to_liquid["redirect_from"].is_a?(Array)
        to_liquid["redirect_from"].compact
      else
        [to_liquid["redirect_from"]].compact
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jekyll-redirect-from-0.16.0 lib/jekyll-redirect-from/redirectable.rb
jekyll-redirect-from-0.15.0 lib/jekyll-redirect-from/redirectable.rb
jekyll-redirect-from-0.14.0 lib/jekyll-redirect-from/redirectable.rb
jekyll-redirect-from-0.13.0 lib/jekyll-redirect-from/redirectable.rb