feat: support npm scoped package specifiers for plugins

Plugins can now be referenced as "@quartz-community/<name>" in
quartz.config.yaml and via 'quartz plugin add'. The npm path skips
git installation and resolves from node_modules.

Changes:
- gitLoader.ts: detect @scope/name as npm package in parsePluginSource()
- config-loader.ts: skip git install for npm packages, read manifests
  from node_modules via createRequire
- install-plugins.ts: filter npm packages from prebuild, fallback to
  YAML config parsing to avoid loading full quartz.ts
- plugin-data.js: npm detection in CLI parseGitSource()
- plugin-git-handlers.js: npm install path in handlePluginAdd()
- package.json: add missing hast-util-from-html dependency
This commit is contained in:
saberzero1
2026-07-23 01:17:53 +02:00
parent 9cf87ff1c2
commit 5b34917e98
7 changed files with 369 additions and 8 deletions
+8
View File
@@ -31,6 +31,8 @@ export interface GitPluginSpec {
subdir?: string
/** Whether this is a local path source */
local?: boolean
/** Whether this is an npm package (installed in node_modules) */
npmPackage?: boolean
}
export type PluginInstallSource = string | GitPluginSpec
@@ -87,6 +89,7 @@ export function parsePluginSource(source: PluginSource): GitPluginSpec {
ref: ref || expanded.ref || undefined,
subdir,
local: expanded.local,
npmPackage: expanded.npmPackage,
}
}
@@ -129,6 +132,11 @@ export function parsePluginSource(source: PluginSource): GitPluginSpec {
return { name, repo: url, ref: ref || undefined }
}
// Handle npm scoped packages (e.g. @quartz-community/syntax-highlighting)
if (typeof source === "string" && source.startsWith("@") && source.includes("/") && !source.includes(":")) {
return { name: source, repo: "", npmPackage: true }
}
// Assume it's a plain repo name and try github
const parts = source.split("/")
if (parts.length === 2) {