-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix
Module not found: Can't resolve 'nextra-theme-docs/style.css'
f…
…or imported markdown files that located outside of CWD (#1332) * fix * update snapshots * Update packages/nextra/src/compile.ts Co-authored-by: Shu Ding <g@shud.in> Co-authored-by: Shu Ding <g@shud.in>
- Loading branch information
1 parent
624d6b4
commit 4b2052f
Showing
9 changed files
with
125 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'nextra': patch | ||
'nextra-theme-docs': patch | ||
--- | ||
|
||
fix `Module not found: Can't resolve 'nextra-theme-docs/style.css'` for imported markdown files that located outside of CWD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { parseMeta, attachMeta } from './rehype' | ||
export { remarkHeadings } from './remark-headings' | ||
export { remarkReplaceImports } from './remark-replace-imports' | ||
export { remarkStaticImage } from './static-image' | ||
export { structurize } from './structurize' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { createRequire } from 'node:module' | ||
import { visit } from 'unist-util-visit' | ||
import { Plugin } from 'unified' | ||
import { Root } from 'mdast' | ||
|
||
const require = createRequire(import.meta.url) | ||
|
||
/** | ||
* Markdown files that imported outside CWD could not find `nextra/mdx` or `next/image` | ||
* to fix it we need to replace import path with absolute for them | ||
* https://github.com/shuding/nextra/issues/1303 | ||
*/ | ||
export const remarkReplaceImports: Plugin<[], Root> = () => { | ||
return (tree, _file, done) => { | ||
visit(tree, 'mdxjsEsm', (node: any) => { | ||
const { source } = node.data.estree.body[0] | ||
const absolutePath = require.resolve(source.value) | ||
|
||
source.value = absolutePath | ||
source.raw = `"${absolutePath}"` | ||
}) | ||
done() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4b2052f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nextra-v2 – ./docs
nextra-v2-git-main-shuding1.vercel.app
nextra-v2-shuding1.vercel.app
nextra.site
nextra.vercel.app
nextra-v2.vercel.app
www.nextra.site