Core: Enable npm install prefix fallback only on old alias

This commit is contained in:
Fuma Nama
2025-08-24 20:02:15 +08:00
parent c520980302
commit 08eee2b556
2 changed files with 14 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-core': patch
---
[`remark-npm`] Enable `npm install` prefix fallback only on old alias
+9 -4
View File
@@ -45,11 +45,16 @@ export function remarkNpm({
return (tree) => {
visit(tree, 'code', (node) => {
if (!node.lang || !aliases.includes(node.lang)) return 'skip';
let value = node.value;
if (
node.lang === 'package-install' &&
!value.startsWith('npm') &&
!value.startsWith('npx')
) {
value = `npm install ${value}`;
}
const value =
node.value.startsWith('npm') || node.value.startsWith('npx')
? node.value
: `npm install ${node.value}`;
const attributes: MdxJsxAttribute[] = [
{
type: 'mdxJsxAttribute',