nanoc / features

Collection of feature requests
2 stars 1 forks source link

item metadata for items with overlapping names #34

Open iay opened 6 years ago

iay commented 6 years ago

At the moment, if you have multiple items whose names only differ in their extension, and at least one of them is binary, your options for getting metadata onto those items are very limited:

One possibility would be to allow x.y.yaml to supply metadata for x.y if present.

My workround for this is to have a sideways.yaml like this:

#
# Metadata to apply to other items.
#
# Use this to, for example, get around the fact that you can't apply
# independent metadata to two items whose names only differ by extension.
# This is relevant when one or the other (or both) are binary.
#
# "apply" is a hash keyed by item identifiers (which will end up as symbols
# once ingested). The values are hashes of key=>value for each attribute
# to be set on the target item.
#
apply:
  '/static/ca/iay-ca-g1-2006.cer':
    redirects: /ca/iay-ca-g1-2006.cer
  '/static/ca/iay-ca-g1-2006.crt':
    redirects: /ca/iay-ca-g1-2006.crt
  '/static/ca/iay-ca-g1-2011.cer':
    redirects: /ca/iay-ca-g1-2011.cer
  '/static/ca/iay-ca-g1-2011.crt':
    redirects: /ca/iay-ca-g1-2011.crt

In the preprocess rule:

  #
  # Apply sideways metadata.
  #
  @items['/sideways.yaml'][:apply].each do |id, md|
    item = @items[id.to_s]
    md.each do |key, value|
      item[key] = value
    end
  end

That works, but there's no part of it that I like.

denisdefreyne commented 6 years ago

I like the idea of using x.y.yaml as the metadata file for x.y!