nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.07k stars 622 forks source link

Error when adding a new remark plugin ? #1552

Open mathieunicolas opened 1 year ago

mathieunicolas commented 1 year ago

Environment

Reproduction

I want to install the remark-admonitions plugin, and here's what I did : npm i --save-dev remark-admonitions

I tried different ways for adding the plugin :

import admonitions from 'remark-admonitions';

export default defineNuxtConfig({
(...)
content: {
    markdown: {
      remarkPlugins: {
        'remark-admonitions': {},
      },
    },

from here, I got an error : [nuxt] [request error] [unhandled] [500] Cannot read properties of undefined (reading 'blockTokenizers')

So I tried the way it is described in the only ref given when talking about custom plugins : https://github.com/nuxt/content/blob/main/src/runtime/markdown-parser/index.ts#L23

and I got the same error : [nuxt] [request error] [unhandled] [500] Cannot read properties of undefined (reading 'blockTokenizers')

  content: {
    markdown: {
      remarkPlugins: {
        'remark-admonitions': {
          instance: admonitions,
        },
      },
    },

Describe the bug

It's probably not a bug, but since I can't read any example I feel like I try copying one source or an other, and I can't make it work.

I'd like to import a remark plugin, and be able to customize its options.

Thanks for your help, hope my post is alright, did my best. Cheers from France !

Additional context

No response

Logs

ERROR  (node:84522) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

ℹ Vite client warmed up in 762ms                                              14:57:58
✔ Nitro built in 853 ms                                                 nitro 14:57:59
(node:84522) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
[nuxt] [request error] [unhandled] [500] Cannot read properties of undefined (reading 'blockTokenizers')
  at Function.attacher (./node_modules/remark-admonitions/lib/index.js:214:10)  
  at Function.freeze (./node_modules/unified/lib/index.js:136:36)  
  at Function.process (./node_modules/unified/lib/index.js:375:15)  
  at ./.nuxt/dev/index.mjs:1734:12  
  at new Promise (<anonymous>)  
  at generateBody (./.nuxt/dev/index.mjs:1725:10)  
  at parse (./.nuxt/dev/index.mjs:1807:22)  
  at async Object.parse (./.nuxt/dev/index.mjs:1852:20)  
  at async transformContent (./.nuxt/dev/index.mjs:2004:18)  
  at async parseContent (./.nuxt/dev/index.mjs:2251:18)
[nuxt] [request error] [unhandled] [500] Cannot read properties of undefined (reading 'blockTokenizers')
  at Function.attacher (./node_modules/remark-admonitions/lib/index.js:214:10)  
  at Function.freeze (./node_modules/unified/lib/index.js:136:36)  
  at Function.process (./node_modules/unified/lib/index.js:375:15)  
  at ./.nuxt/dev/index.mjs:1734:12  
  at new Promise (<anonymous>)  
  at generateBody (./.nuxt/dev/index.mjs:1725:10)  
  at parse (./.nuxt/dev/index.mjs:1807:22)  
  at async Object.parse (./.nuxt/dev/index.mjs:1852:20)  
  at async transformContent (./.nuxt/dev/index.mjs:2004:18)  
  at async parseContent (./.nuxt/dev/index.mjs:2251:18)
[nuxt] [request error] [unhandled] [500] Cannot read properties of undefined (reading 'blockTokenizers')
  at Function.attacher (./node_modules/remark-admonitions/lib/index.js:214:10)  
  at Function.freeze (./node_modules/unified/lib/index.js:136:36)  
  at Function.process (./node_modules/unified/lib/index.js:375:15)  
  at ./.nuxt/dev/index.mjs:1734:12  
  at new Promise (<anonymous>)  
  at generateBody (./.nuxt/dev/index.mjs:1725:10)  
  at parse (./.nuxt/dev/index.mjs:1807:22)  
  at async Object.parse (./.nuxt/dev/index.mjs:1852:20)  
  at async transformContent (./.nuxt/dev/index.mjs:2004:18)  
  at async parseContent (./.nuxt/dev/index.mjs:2251:18)
[nuxt] [request error] [unhandled] [500] Cannot read properties of undefined (reading 'blockTokenizers')
  at Function.attacher (./node_modules/remark-admonitions/lib/index.js:214:10)  
  at Function.freeze (./node_modules/unified/lib/index.js:136:36)  
  at Function.process (./node_modules/unified/lib/index.js:375:15)  
  at ./.nuxt/dev/index.mjs:1734:12  
  at new Promise (<anonymous>)  
  at generateBody (./.nuxt/dev/index.mjs:1725:10)  
  at parse (./.nuxt/dev/index.mjs:1807:22)  
  at async Object.parse (./.nuxt/dev/index.mjs:1852:20)  
  at async transformContent (./.nuxt/dev/index.mjs:2004:18)  
  at async parseContent (./.nuxt/dev/index.mjs:2251:18)
farnabaz commented 1 year ago

Seems that remark-admonitions does not support latest remark.