| | |
| | | export const Assets: QuartzEmitterPlugin = () => { |
| | | return { |
| | | name: "Assets", |
| | | getQuartzComponents() { |
| | | return [] |
| | | }, |
| | | async getDependencyGraph(ctx, _content, _resources) { |
| | | const { argv, cfg } = ctx |
| | | const graph = new DepGraph<FilePath>() |
| | |
| | | |
| | | return graph |
| | | }, |
| | | async emit({ argv, cfg }, _content, _resources): Promise<FilePath[]> { |
| | | async *emit({ argv, cfg }, _content, _resources) { |
| | | const assetsPath = argv.output |
| | | const fps = await filesToCopy(argv, cfg) |
| | | const res: FilePath[] = [] |
| | | for (const fp of fps) { |
| | | const ext = path.extname(fp) |
| | | const src = joinSegments(argv.directory, fp) as FilePath |
| | |
| | | const dir = path.dirname(dest) as FilePath |
| | | await fs.promises.mkdir(dir, { recursive: true }) // ensure dir exists |
| | | await fs.promises.copyFile(src, dest) |
| | | res.push(dest) |
| | | yield dest |
| | | } |
| | | |
| | | return res |
| | | }, |
| | | } |
| | | } |