Skip to content

Commit 8df8d5c

Browse files
Nambersjackyzha0
andauthored
fix: fix CNAME path error (#2096)
* fix: fix CNAME path error * chore: Update quartz/plugins/emitters/cname.ts Co-authored-by: Jacky Zhao <[email protected]> * chore: remove unused import --------- Co-authored-by: Jacky Zhao <[email protected]>
1 parent ac06a52 commit 8df8d5c

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

quartz/plugins/emitters/cname.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { FilePath, joinSegments } from "../../util/path"
21
import { QuartzEmitterPlugin } from "../types"
3-
import fs from "fs"
2+
import { write } from "./helpers"
43
import { styleText } from "util"
4+
import { FullSlug } from "../../util/path"
55

66
export function extractDomainFromBaseUrl(baseUrl: string) {
77
const url = new URL(`https://${baseUrl}`)
@@ -10,20 +10,25 @@ export function extractDomainFromBaseUrl(baseUrl: string) {
1010

1111
export const CNAME: QuartzEmitterPlugin = () => ({
1212
name: "CNAME",
13-
async emit({ argv, cfg }) {
14-
if (!cfg.configuration.baseUrl) {
13+
async emit(ctx) {
14+
if (!ctx.cfg.configuration.baseUrl) {
1515
console.warn(
1616
styleText("yellow", "CNAME emitter requires `baseUrl` to be set in your configuration"),
1717
)
1818
return []
1919
}
20-
const path = joinSegments(argv.output, "CNAME")
21-
const content = extractDomainFromBaseUrl(cfg.configuration.baseUrl)
20+
const content = extractDomainFromBaseUrl(ctx.cfg.configuration.baseUrl)
2221
if (!content) {
2322
return []
2423
}
25-
await fs.promises.writeFile(path, content)
26-
return [path] as FilePath[]
24+
25+
const path = await write({
26+
ctx,
27+
content,
28+
slug: "CNAME" as FullSlug,
29+
ext: "",
30+
})
31+
return [path]
2732
},
2833
async *partialEmit() {},
2934
})

0 commit comments

Comments
 (0)