2023-08-17 05:04:15 +00:00
|
|
|
import { FilePath, QUARTZ, joinSegments } from "../../util/path"
|
2023-07-24 00:07:19 +00:00
|
|
|
import { QuartzEmitterPlugin } from "../types"
|
|
|
|
import fs from "fs"
|
2023-08-17 05:04:15 +00:00
|
|
|
import { glob } from "../../util/glob"
|
2024-02-09 15:07:32 +00:00
|
|
|
import DepGraph from "../../depgraph"
|
2023-07-24 00:07:19 +00:00
|
|
|
|
|
|
|
export const Static: QuartzEmitterPlugin = () => ({
|
|
|
|
name: "Static",
|
|
|
|
getQuartzComponents() {
|
|
|
|
return []
|
|
|
|
},
|
2024-02-09 15:07:32 +00:00
|
|
|
async getDependencyGraph({ argv, cfg }, _content, _resources) {
|
|
|
|
const graph = new DepGraph<FilePath>()
|
|
|
|
|
|
|
|
const staticPath = joinSegments(QUARTZ, "static")
|
|
|
|
const fps = await glob("**", staticPath, cfg.configuration.ignorePatterns)
|
|
|
|
for (const fp of fps) {
|
|
|
|
graph.addEdge(
|
|
|
|
joinSegments("static", fp) as FilePath,
|
|
|
|
joinSegments(argv.output, "static", fp) as FilePath,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
return graph
|
|
|
|
},
|
2024-01-18 18:56:14 +00:00
|
|
|
async emit({ argv, cfg }, _content, _resources): Promise<FilePath[]> {
|
2023-08-03 06:04:26 +00:00
|
|
|
const staticPath = joinSegments(QUARTZ, "static")
|
2023-08-03 05:10:13 +00:00
|
|
|
const fps = await glob("**", staticPath, cfg.configuration.ignorePatterns)
|
2023-11-15 17:43:30 +00:00
|
|
|
await fs.promises.cp(staticPath, joinSegments(argv.output, "static"), {
|
|
|
|
recursive: true,
|
|
|
|
dereference: true,
|
|
|
|
})
|
2023-08-12 06:25:44 +00:00
|
|
|
return fps.map((fp) => joinSegments(argv.output, "static", fp)) as FilePath[]
|
2023-07-24 00:07:19 +00:00
|
|
|
},
|
|
|
|
})
|