Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
hopoduck opened this issue Jan 30, 2024 · 3 comments
Closed

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

hopoduck opened this issue Jan 30, 2024 · 3 comments

Comments

@hopoduck
Copy link

hopoduck commented Jan 30, 2024

Environment

Nuxt project info:


  • Operating System: Windows_NT
  • Node Version: v20.11.0
  • Nuxt Version: 3.9.1
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: yarn@1.22.21
  • Builder: -
  • User Config: devtools, modules, ui, app, content, googleFonts
  • Runtime Modules: @nuxt/ui@2.11.1, nuxt-icon@0.6.7, @nuxtjs/google-fonts@3.1.1, @nuxtjs/fontaine@0.4.1, @nuxt/image@1.1.0, @nuxt/content@2.11.0, @nuxthq/studio@1.0.6, @vueuse/nuxt@10.7.2, @nuxt/image@1.1.0
  • Build Modules: -

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

Copy link

stackblitz bot commented Jan 30, 2024

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

@hopoduck hopoduck changed the title How can I pass a function to the option of remarkPlugins in nuxt.config.ts? Cannot use function in option of remarkPlugins in nuxt.config.ts Jan 30, 2024
@danielroe danielroe transferred this issue from nuxt/nuxt Jan 30, 2024
@farnabaz
Copy link
Member

farnabaz commented Feb 2, 2024

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

@hopoduck
Copy link
Author

hopoduck commented Feb 3, 2024

thank you I will check the details.

@hopoduck hopoduck closed this as completed Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants