Sha256: 18900e3152f3f2a278d82f17f7f29d0da2fded4b672b50560dc06f6c34e5d1a2
Contents?: true
Size: 1.21 KB
Versions: 3
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true module Bridgetown module Resource class TaxonomyType using Bridgetown::Refinements # @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).as_dots 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 def to_json(...) as_json(...).to_json(...) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems