davestewart/nuxt-content-assets

Better targeting in markup for path transformation

davestewart opened this issue · 1 comments

Background

Right now, supported tags and attributes are internally configured.

This means that whilst an <img src=""> will have its src transformed, <CustomImage image="" /> will not.

Proposal

Some way to configure per asset or per attribute what to transform, for example, default config:

{
  attrsMap: {
    'a': 'href',
    '*': 'src',
    'CustomImage': 'image',
  }
}

This would target:

  • anchor tags
  • anything with a src attribute
  • CustomImage component's image attribute

Maybe even:

{
  attrsMap: {
    '*': 'href src',
    'CustomImage': 'image',
  }
}

Or maybe even simply test visited nodes to be elements, then test any string prop against the hash of paths 👍

Closed by #11