Sha256: ccac8b77a4f5a6cbb92c0daa2c41d768b2bf7d4c04b0d8452900437add33ff7b

Contents?: true

Size: 1.6 KB

Versions: 10

Compression:

Stored size: 1.6 KB

Contents

# encoding: UTF-8

module Jekyll
  module Drops
    class UrlDrop < Drop
      extend Forwardable

      mutable false

      def_delegator :@obj, :cleaned_relative_path, :path
      def_delegator :@obj, :output_ext, :output_ext

      def collection
        @obj.collection.label
      end

      def name
        Utils.slugify(@obj.basename_without_ext)
      end

      def title
        Utils.slugify(@obj.data["slug"], :mode => "pretty", :cased => true) ||
          Utils.slugify(@obj.basename_without_ext, :mode => "pretty", :cased => true)
      end

      def slug
        Utils.slugify(@obj.data["slug"]) || Utils.slugify(@obj.basename_without_ext)
      end

      def categories
        category_set = Set.new
        Array(@obj.data["categories"]).each do |category|
          category_set << category.to_s.downcase
        end
        category_set.to_a.join("/")
      end

      def year
        @obj.date.strftime("%Y")
      end

      def month
        @obj.date.strftime("%m")
      end

      def day
        @obj.date.strftime("%d")
      end

      def hour
        @obj.date.strftime("%H")
      end

      def minute
        @obj.date.strftime("%M")
      end

      def second
        @obj.date.strftime("%S")
      end

      def i_day
        @obj.date.strftime("%-d")
      end

      def i_month
        @obj.date.strftime("%-m")
      end

      def short_month
        @obj.date.strftime("%b")
      end

      def short_year
        @obj.date.strftime("%y")
      end

      def y_day
        @obj.date.strftime("%j")
      end

      private
      def fallback_data
        {}
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
jekyll-3.5.2 lib/jekyll/drops/url_drop.rb
jekyll-3.5.1 lib/jekyll/drops/url_drop.rb
jekyll-3.4.5 lib/jekyll/drops/url_drop.rb
jekyll-3.5.0 lib/jekyll/drops/url_drop.rb
jekyll-3.4.4 lib/jekyll/drops/url_drop.rb
jekyll-3.4.3 lib/jekyll/drops/url_drop.rb
jekyll-3.4.2 lib/jekyll/drops/url_drop.rb
jekyll-3.4.1 lib/jekyll/drops/url_drop.rb
jekyll-3.4.0 lib/jekyll/drops/url_drop.rb
jekyll-3.3.1 lib/jekyll/drops/url_drop.rb