Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 08eee2b

Browse files
committed
Core: Enable npm install prefix fallback only on old alias
1 parent c520980 commit 08eee2b

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

.changeset/wide-gifts-brush.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'fumadocs-core': patch
3+
---
4+
5+
[`remark-npm`] Enable `npm install` prefix fallback only on old alias

packages/core/src/mdx-plugins/remark-npm.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,16 @@ export function remarkNpm({
4545
return (tree) => {
4646
visit(tree, 'code', (node) => {
4747
if (!node.lang || !aliases.includes(node.lang)) return 'skip';
48+
let value = node.value;
49+
50+
if (
51+
node.lang === 'package-install' &&
52+
!value.startsWith('npm') &&
53+
!value.startsWith('npx')
54+
) {
55+
value = `npm install ${value}`;
56+
}
4857

49-
const value =
50-
node.value.startsWith('npm') || node.value.startsWith('npx')
51-
? node.value
52-
: `npm install ${node.value}`;
5358
const attributes: MdxJsxAttribute[] = [
5459
{
5560
type: 'mdxJsxAttribute',

0 commit comments

Comments
 (0)