mirror of
https://github.com/jackyzha0/quartz.git
synced 2026-03-21 21:45:42 -05:00
feat: support array categories in plugin manifests
Plugins like note-properties export both transformer and component functionality. Allow PluginManifest.category to be a single value or an array, with config-loader resolving to the first processing category (transformer/filter/emitter/pageType) for dispatch.
This commit is contained in:
parent
6b9629032e
commit
6562fb9320
@ -258,8 +258,17 @@ export async function loadQuartzConfig(): Promise<QuartzConfig> {
|
||||
for (const entry of enabledEntries) {
|
||||
const manifest = manifests.get(entry.source)
|
||||
const category = manifest?.category
|
||||
// Resolve processing category: for array categories (e.g. ["transformer", "component"]),
|
||||
// find the first processing category. "component" is handled separately via loadComponentsFromPackage.
|
||||
const processingCategories = ["transformer", "filter", "emitter", "pageType"] as const
|
||||
let resolvedCategory: string | undefined
|
||||
if (Array.isArray(category)) {
|
||||
resolvedCategory = category.find((c) => (processingCategories as readonly string[]).includes(c))
|
||||
} else {
|
||||
resolvedCategory = category
|
||||
}
|
||||
|
||||
switch (category) {
|
||||
switch (resolvedCategory) {
|
||||
case "transformer":
|
||||
transformers.push({ entry, manifest })
|
||||
break
|
||||
@ -358,7 +367,7 @@ export async function loadQuartzConfig(): Promise<QuartzConfig> {
|
||||
|
||||
// Import built-in plugins
|
||||
const builtinPlugins = await import("../index")
|
||||
const builtinTransformers = [builtinPlugins.FrontMatter()]
|
||||
const builtinTransformers: unknown[] = []
|
||||
const builtinEmitters = [
|
||||
builtinPlugins.ComponentResources(),
|
||||
builtinPlugins.Assets(),
|
||||
|
||||
@ -49,7 +49,7 @@ export interface PluginManifest {
|
||||
author?: string
|
||||
homepage?: string
|
||||
keywords?: string[]
|
||||
category?: PluginCategory
|
||||
category?: PluginCategory | PluginCategory[]
|
||||
quartzVersion?: string
|
||||
/** Plugin sources this plugin depends on (e.g., "github:quartz-community/crawl-links") */
|
||||
dependencies?: string[]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user