davestewart / nuxt-content-assets

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

Optimise AST parsing #14

Closed davestewart closed 1 year ago

davestewart commented 1 year ago

Background

When testing NCA on Pinia ORM's docs, setup fails when attempting to process an element's props.

Not only that, but parsing the entire document hits transformed code blocks, which contain a LOT of child elements!

So it looks like the strategy to visit all nodes needs more work 😬

Proposal

When visiting nodes we need to know:

  1. should its children be processed?
  2. should its attributes be processed?
  3. could this element have an asset link?

Regardless of whether we continue with the "process all tags" approach, to optimise we'll need to know which HTML tags could be optimised against unnecessary traversal, for example, code and pre.

Likely known HTML tags should be added to a list and this should be checked against.

Notes

The alternative to processing all elements would be to go back to only processing configured known and custom elements.