Sha256: 6d4836d2e589eab3fa740466a4b5679c04c3d4e6458d7b0d3c5fd83ff0fa9f4f
Contents?: true
Size: 1.21 KB
Versions: 16
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true module Bridgetown module Resource class TaxonomyType # @return [Bridgetown::Site] attr_reader :site # @return [String] aka `category`, `tag`, `region`, etc. attr_reader :label # @return [String] the key used in front matter attr_reader :key # @return [HashWithDotAccess::Hash] any associated metadata attr_reader :metadata # @param site [Bridgetown::Site] # @param label [String] # @param key [String] def initialize(site:, label:, key:, metadata:) @site = site @label = label @key = key @metadata = metadata end def terms site.resources.map do |resource| resource.taxonomies[label].terms end.flatten.group_by(&:label).with_dot_access end def inspect "#<#{self.class} label=#{label}>" end def to_liquid { "label" => label, "key" => key, "metadata" => metadata, } end alias_method :to_h, :to_liquid def as_json(*) to_h end ruby2_keywords def to_json(*options) as_json(*options).to_json(*options) end end end end
Version data entries
16 entries across 16 versions & 1 rubygems