如何在 nuxt.js 中使用 markdown-it 插件选项

Hor*_*zon 5 javascript nuxt.js markdown-it

我用来@nuxtjs/markdownit解析 markdown 文件,我想在'markdown-it-anchor'插件中启用创建永久链接功能,我使用了以下代码nuxt.config.js但不起作用:

\n\n
  modules: [\n    // Doc: https://axios.nuxtjs.org/usage\n    '@nuxtjs/axios',\n    '@nuxtjs/markdownit'\n  ],\n  markdownit: {\n    preset: 'default',\n    linkify: true,\n    breaks: true,\n    typographer: true,\n    html: false,\n    use: [\n      'markdown-it-anchor',\n      'markdown-it-attrs',\n      'markdown-it-div',\n      'markdown-it-toc-done-right',\n      'markdown-it-emoji'\n    ]\n  },\n  'markdown-it-anchor': {\n    level: 1,\n    // slugify: string => string,\n    permalink: true,\n    // renderPermalink: (slug, opts, state, permalink) => {},\n    permalinkClass: 'header-anchor',\n    permalinkSymbol: '\xc2\xb6',\n    permalinkBefore: true\n  },\n
Run Code Online (Sandbox Code Playgroud)\n

Hor*_*zon 4

自我回答:我在这篇文章中找到了语法

\n\n
markdownit: {\n    preset: \'default\',\n    linkify: true,\n    breaks: true,\n    typographer: true,\n    html: false,\n    use: [\n      [\n        \'markdown-it-anchor\',\n        {\n          level: 1,\n          // slugify: string => string,\n          permalink: true,\n          // renderPermalink: (slug, opts, state, permalink) => {},\n          permalinkClass: \'header-anchor\',\n          permalinkSymbol: \'\xc2\xb6\',\n          permalinkBefore: true\n        }\n      ],\n      \'markdown-it-attrs\',\n      \'markdown-it-div\',\n      \'markdown-it-toc-done-right\',\n      \'markdown-it-emoji\'\n    ]\n  },\n\n
Run Code Online (Sandbox Code Playgroud)\n