davestewart / nuxt-content-assets

Enable locally-located assets in Nuxt Content
https://npmjs.com/package/nuxt-content-assets
108 stars 7 forks source link

Better targeting in markup for path transformation #8

Closed davestewart closed 1 year ago

davestewart commented 1 year ago

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:

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 👍

davestewart commented 1 year ago

Closed by #11