nuxt / content

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

Cannot use function in option of remarkPlugins in `nuxt.config.ts` #2532

Closed hopoduck closed 7 months ago

hopoduck commented 8 months ago

Environment

Nuxt project info:


Reproduction

https://stackblitz.com/edit/github-khom7f?file=nuxt.config.ts

Describe the bug

This is my nuxt.config.ts content.

export default defineNuxtConfig({
  devtools: { enabled: true },
  modules: [
    "@nuxt/ui",
    "nuxt-icon",
    "@nuxtjs/google-fonts",
    "@nuxtjs/fontaine",
    "@nuxt/image",
    "@nuxt/content",
    "@nuxthq/studio",
    "@vueuse/nuxt",
    "@nuxt/image",
  ],
  // ...
  content: {
    markdown: {
      toc: {
        depth: 2,
        searchDepth: 3,
      },
      remarkPlugins: {
        "remark-wiki-link": {
          wikiLinkClassName: "internal-wiki-link",
          hrefTemplate: (permalink: string) => {
            return `articles/${permalink}`;
          },
        },
      },
    },
  },
});

It uses remarkPlugin, where wikiLinkClassName receives a string as a parameter, and hrefTemplate receives a function as a parameter. When executing with this option given, the hrefTemplate key itself will not be passed, so the default value will be used.

Is there any way to use this option?

Additional context

No response

Logs

No response

stackblitz[bot] commented 8 months ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

farnabaz commented 7 months ago

It is not possible to read a function from nuxt.config. Functions will be supported in next release which implemented in https://github.com/nuxt-modules/mdc/pull/129

hopoduck commented 7 months ago

thank you I will check the details.