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) {
|
for (const entry of enabledEntries) {
|
||||||
const manifest = manifests.get(entry.source)
|
const manifest = manifests.get(entry.source)
|
||||||
const category = manifest?.category
|
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":
|
case "transformer":
|
||||||
transformers.push({ entry, manifest })
|
transformers.push({ entry, manifest })
|
||||||
break
|
break
|
||||||
@ -358,7 +367,7 @@ export async function loadQuartzConfig(): Promise<QuartzConfig> {
|
|||||||
|
|
||||||
// Import built-in plugins
|
// Import built-in plugins
|
||||||
const builtinPlugins = await import("../index")
|
const builtinPlugins = await import("../index")
|
||||||
const builtinTransformers = [builtinPlugins.FrontMatter()]
|
const builtinTransformers: unknown[] = []
|
||||||
const builtinEmitters = [
|
const builtinEmitters = [
|
||||||
builtinPlugins.ComponentResources(),
|
builtinPlugins.ComponentResources(),
|
||||||
builtinPlugins.Assets(),
|
builtinPlugins.Assets(),
|
||||||
|
|||||||
@ -49,7 +49,7 @@ export interface PluginManifest {
|
|||||||
author?: string
|
author?: string
|
||||||
homepage?: string
|
homepage?: string
|
||||||
keywords?: string[]
|
keywords?: string[]
|
||||||
category?: PluginCategory
|
category?: PluginCategory | PluginCategory[]
|
||||||
quartzVersion?: string
|
quartzVersion?: string
|
||||||
/** Plugin sources this plugin depends on (e.g., "github:quartz-community/crawl-links") */
|
/** Plugin sources this plugin depends on (e.g., "github:quartz-community/crawl-links") */
|
||||||
dependencies?: string[]
|
dependencies?: string[]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user