Add local remark plugin
See original GitHub issueEnvironment
- Operating System:
Windows_NT
- Node Version:
v16.13.1
- Nuxt Version:
3.0.0-rc.6
- Package Manager:
npm@8.1.2
- Builder:
vite
- User Config:
app
,typescript
,modules
,colorMode
,content
- Runtime Modules:
@nuxt/content@2.1.0-27639343.b832f24
,@nuxtjs/tailwindcss@5.3.0
,@nuxtjs/color-mode@3.1.4
- Build Modules:
-
Reproduction
https://github.com/Benbinbin/nuxt-content-local-remark-plugin
Describe the bug
The former documentation show how to use the local remark plugin, like ~/markdownPlugins/remark-plugin.js
but the new documentation delete this part
when I use the same syntax which is mentioned at the old documentation
export default defineNuxtConfig({
// ...
content: {
// ...
markdown: {
remarkPlugins: ['~/markdownPlugins/remarkPlugin.js']
}
}
})
but then I get an error (see th Logs part 👇 ) it recognizes the local remark plugin file as a package?
maybe the old documentation just suitable for content v1, any new way to add local remark plugin for content v2?
Additional context
some relative issues about plugin:
Logs
[nuxt] [request error] Cannot find package '~' imported from D:\Work\Code\Web\Frontend\Nuxt\nuxt-content-local-remark-plugin\.nuxt\dev\index.mjs
at new NodeError (node:internal/errors:371:5)
at packageResolve (node:internal/modules/esm/resolve:884:9)
at moduleResolve (node:internal/modules/esm/resolve:929:18)
at defaultResolve (node:internal/modules/esm/resolve:1044:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
at ESMLoader.import (node:internal/modules/esm/loader:276:22)
at importModuleDynamically (node:internal/modules/esm/translators:111:35)
at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
at importPlugins (/D:/Work/Code/Web/Frontend/Nuxt/nuxt-content-local-remark-plugin/.nuxt/dev/index.mjs:1096:32)
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Creating a Remark Transformer Plugin - Gatsby
First create a local plugin by adding a plugins folder in your site and generating a package.json file for it. As well, create...
Read more >remark-plugin - Topics - unified
Explore projects in the unified ecosystem with the “remark-plugin” topic.
Read more >Writing plugins for remark and gatsby-transformer-remark (part ...
In my mind, the ideal solution should be able to recognize foreign GitHub links in a Markdown file, fetch and insert them into...
Read more >to-gatsby-remark-plugin - npm
Create a file locally with the following code. ... const toGatsbyRemarkPlugin = require('to-gatsby-remark-plugin');. const myRemarkPlugin = ...
Read more >Markdown & MDX - Astro Documentation
You can add frontmatter properties to all of your Markdown and MDX files by using a remark or rehype plugin. Append a customProperty...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is a debug memo.
Nuxt Content v2 dynamically
import
s plugins without resolving Nuxt aliases, so they are assumed to be insidenode_modules
.https://github.com/nuxt/content/blob/ede65e8337ca3eb597af95c17cfc609e4015238c/src/runtime/server/transformers/markdown.ts#L25-L38
Nuxt Content v1 resolves aliases by resolver:
https://github.com/nuxt/content/blob/776e428eb2987e5a8c237fbc90e2d9beb8e3b0e3/packages/content/lib/utils.js#L58-L83
@Benbinbin Amazing! BTW, your website’s Table of Contents is just next level. It’s magical… 😮👍🏻
Image