mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-27 14:54:05 -06:00
feat(emitter): BuildOnly
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
parent
1ab9c91df1
commit
8df53a8542
34
quartz/plugins/emitters/build.ts
Normal file
34
quartz/plugins/emitters/build.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { QuartzComponent } from "../../components/types"
|
||||||
|
import DepGraph from "../../depgraph"
|
||||||
|
import { BuildCtx } from "../../util/ctx"
|
||||||
|
import { FilePath } from "../../util/path"
|
||||||
|
import { StaticResources } from "../../util/resources"
|
||||||
|
import { QuartzEmitterPlugin, QuartzEmitterPluginInstance } from "../types"
|
||||||
|
import { ProcessedContent } from "../vfile"
|
||||||
|
|
||||||
|
interface Options {
|
||||||
|
emitter: QuartzEmitterPluginInstance
|
||||||
|
}
|
||||||
|
|
||||||
|
export const BuildOnly: QuartzEmitterPlugin<Options> = (opts) => {
|
||||||
|
const emitter = opts?.emitter as QuartzEmitterPluginInstance
|
||||||
|
return {
|
||||||
|
name: `BuildOnly<${emitter.name}>`,
|
||||||
|
getQuartzComponents(ctx: BuildCtx): QuartzComponent[] {
|
||||||
|
if (ctx.argv.serve) return []
|
||||||
|
return emitter.getQuartzComponents(ctx)
|
||||||
|
},
|
||||||
|
async getDependencyGraph(
|
||||||
|
ctx: BuildCtx,
|
||||||
|
content: ProcessedContent[],
|
||||||
|
resources: StaticResources,
|
||||||
|
) {
|
||||||
|
if (ctx.argv.serve) return new DepGraph<FilePath>()
|
||||||
|
return await emitter.getDependencyGraph!(ctx, content, resources)
|
||||||
|
},
|
||||||
|
async emit(ctx: BuildCtx, content: ProcessedContent[], resources: StaticResources) {
|
||||||
|
if (ctx.argv.serve) return []
|
||||||
|
return emitter.emit(ctx, content, resources)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,3 +8,4 @@ export { Static } from "./static"
|
|||||||
export { ComponentResources } from "./componentResources"
|
export { ComponentResources } from "./componentResources"
|
||||||
export { NotFoundPage } from "./404"
|
export { NotFoundPage } from "./404"
|
||||||
export { CNAME } from "./cname"
|
export { CNAME } from "./cname"
|
||||||
|
export { BuildOnly } from "./build"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user