mirror of
https://gitlab.com/MisterBiggs/brain-quartz.git
synced 2025-08-20 12:24:55 +00:00
.github
content
docs
quartz
cli
components
i18n
plugins
emitters
404.tsx
aliases.ts
assets.ts
cname.ts
componentResources.ts
contentIndex.tsx
contentPage.tsx
favicon.ts
folderPage.tsx
helpers.ts
index.ts
ogImage.tsx
static.ts
tagPage.tsx
filters
transformers
index.ts
types.ts
vfile.ts
processors
static
styles
util
bootstrap-cli.mjs
bootstrap-worker.mjs
build.ts
cfg.ts
worker.ts
.gitattributes
.gitignore
.node-version
.npmrc
.prettierignore
.prettierrc
CODE_OF_CONDUCT.md
Dockerfile
LICENSE.txt
README.md
globals.d.ts
index.d.ts
package-lock.json
package.json
quartz.config.ts
quartz.layout.ts
tsconfig.json
* checkpoint * make emitters async generators * fix * custom font spec * replace spinner, use disk cache for fonts * use readline instead * make og images look nice
21 lines
643 B
TypeScript
21 lines
643 B
TypeScript
import path from "path"
|
|
import fs from "fs"
|
|
import { BuildCtx } from "../../util/ctx"
|
|
import { FilePath, FullSlug, joinSegments } from "../../util/path"
|
|
import { Readable } from "stream"
|
|
|
|
type WriteOptions = {
|
|
ctx: BuildCtx
|
|
slug: FullSlug
|
|
ext: `.${string}` | ""
|
|
content: string | Buffer | Readable
|
|
}
|
|
|
|
export const write = async ({ ctx, slug, ext, content }: WriteOptions): Promise<FilePath> => {
|
|
const pathToPage = joinSegments(ctx.argv.output, slug + ext) as FilePath
|
|
const dir = path.dirname(pathToPage)
|
|
await fs.promises.mkdir(dir, { recursive: true })
|
|
await fs.promises.writeFile(pathToPage, content)
|
|
return pathToPage
|
|
}
|