docs on making plugins

This commit is contained in:
Jacky Zhao 2023-08-10 21:16:07 -07:00
parent ad3f7b2d5f
commit cefbca4753
11 changed files with 330 additions and 43 deletions

View file

@ -30,9 +30,8 @@ export const AliasRedirects: QuartzEmitterPlugin = () => ({
for (const alias of aliases) {
const slug = path.posix.join(dir, alias) as ServerSlug
const fp = (slug + ".html") as FilePath
const redirUrl = resolveRelative(canonicalizeServer(slug), ogSlug)
await emit({
const fp = await emit({
content: `
<!DOCTYPE html>
<html lang="en-us">

View file

@ -98,7 +98,6 @@ function addGlobalPageResources(
componentResources.afterDOMLoaded.push(plausibleScript)
}
// spa
if (cfg.enableSPA) {
componentResources.afterDOMLoaded.push(spaRouterScript)
} else {

View file

@ -88,21 +88,19 @@ export const ContentIndex: QuartzEmitterPlugin<Partial<Options>> = (opts) => {
}
if (opts?.enableSiteMap) {
await emit({
emitted.push(await emit({
content: generateSiteMap(cfg, linkIndex),
slug: "sitemap" as ServerSlug,
ext: ".xml",
})
emitted.push("sitemap.xml" as FilePath)
}))
}
if (opts?.enableRSS) {
await emit({
emitted.push(await emit({
content: generateRSSFeed(cfg, linkIndex),
slug: "index" as ServerSlug,
ext: ".xml",
})
emitted.push("index.xml" as FilePath)
}))
}
const fp = path.join("static", "contentIndex") as ServerSlug
@ -117,12 +115,11 @@ export const ContentIndex: QuartzEmitterPlugin<Partial<Options>> = (opts) => {
}),
)
await emit({
emitted.push(await emit({
content: JSON.stringify(simplifiedIndex),
slug: fp,
ext: ".json",
})
emitted.push(`${fp}.json` as FilePath)
}))
return emitted
},

View file

@ -42,9 +42,7 @@ export const ContentPage: QuartzEmitterPlugin<Partial<FullPageLayout>> = (userOp
}
const content = renderPage(slug, componentData, opts, externalResources)
const fp = (file.data.slug + ".html") as FilePath
await emit({
const fp = await emit({
content,
slug: file.data.slug!,
ext: ".html",

View file

@ -74,9 +74,7 @@ export const FolderPage: QuartzEmitterPlugin<FullPageLayout> = (userOpts) => {
}
const content = renderPage(slug, componentData, opts, externalResources)
const fp = (file.data.slug! + ".html") as FilePath
await emit({
const fp = await emit({
content,
slug: file.data.slug!,
ext: ".html",

View file

@ -80,9 +80,7 @@ export const TagPage: QuartzEmitterPlugin<FullPageLayout> = (userOpts) => {
}
const content = renderPage(slug, componentData, opts, externalResources)
const fp = (file.data.slug + ".html") as FilePath
await emit({
const fp = await emit({
content,
slug: file.data.slug!,
ext: ".html",