【问题标题】:How to use markdown-it plugins options in nuxt.js如何在 nuxt.js 中使用 markdown-it 插件选项
【发布时间】:2020-02-27 15:28:56
【问题描述】:

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

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

【问题讨论】:

    标签: javascript nuxt.js markdown-it


    【解决方案1】:

    自我回答:我在 post 中找到了语法

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-03
      • 2017-09-11
      • 2018-12-19
      • 1970-01-01
      • 2021-11-16
      • 2021-01-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多