davestewart / nuxt-content-assets

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

contentExtensions configuration not working properly #63

Closed ayZagen closed 2 months ago

ayZagen commented 6 months ago

I would like to exclude mdx files from being detected as assets so I included following config as it defined in README:

contentAssets: {
  contentExtensions: 'md mdx yml yaml json',
}

however mdx files are still being treated as asset files and they are copied in public folder. I can also see those files in log output when debug: true is set.

I also tried using regex like configuration like this:

'mdx? ya?ml json'

but it didn't have any effect.

Am I missing something?

davestewart commented 5 months ago

Hey @ayZagen - sorry I've too busy to look at any OSS for a while 😬

Are you still having problems with this?

ayZagen commented 5 months ago

hi there, yes this issue is still valid. i think contentExtensions configuration has no effect at all.

davestewart commented 2 months ago

Sorry again for the delay @ayZagen.

I'm working on various tickets for Nuxt Content Assets right now.

Can I ask – if you're still using this package – did you load Nuxt Content Assets before Nuxt Content as per the docs?

export default defineNuxtConfig({
  modules: [
    'nuxt-content-assets', // make sure to add before content!
    '@nuxt/content',
  ]
})

If not, let me know and I'll attempt to debug this.

ayZagen commented 2 months ago

Yes, I strictly followed readme. I believe this function should be aware of contentExtensions config.

davestewart commented 2 months ago

Thanks for coming back to me.

Let me take a look this afternoon and let you know.

davestewart commented 2 months ago

Just to keep you updated, @ayZagen...

Struggling with getting #76 over the line with some weird side effects to nuxi prepare.

Severely limited on time this week, but this issue is next in line.

At least I'm reacquainted with the code, and fairly sure I know what I'm looking for and where to look for it.

In the meantime, can you see what happens when you set content's ignores config setting directly?

This should do as you ask, above:

export default defineNuxtConfig({
  content: {
    ignores: [
      '\\.(mdx?|ya?ml|json)$',
    ]
  }
})
davestewart commented 2 months ago

Picked this up again today.

i think contentExtensions configuration has no effect at all.

So you're right – and there is a bug – but contentExtensions actually serves a different purpose (and is only included in the docs as an escape hatch in case the internal use of it doesn't do its job).

I'm solving the actual bug (files being copied) in two ways:

  1. clarifying the documentation around contentExtensions
  2. a fix, which prevents recognised content file types (md mdx csv yml yaml json) from being copied to public

Additionally, I'm adding an example to the playground.

Thanks for bringing this to my attention; the new fix will do what you need and I'll get it committed and pushed tonight!

ayZagen commented 2 months ago

Thanks a lot for your effort. I will try it as soon as possible.

davestewart commented 2 months ago

Sorry it took so f---ing long 😆