davestewart / nuxt-content-assets

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

Optimise content parsing hook #26

Open davestewart opened 1 year ago

davestewart commented 1 year ago

Background

Right now, the module hooks into Content's content:file:afterParse hook to process image paths.

The callback hook receives the the markdown AST which – depending on the content – can be quite large.

For example, transformed code can generate many, many spans, so in order to exclude code and potentially other invalid elements, but include custom components we use a tags lookup to determine whether to walk a visited element.

There is possibly the potential to optimise this:

Proposal

Spike the regexp route and see if it's simple / reliable, then look into seeing how the remark plugin approach might work.