run prettier
This commit is contained in:
@ -1,6 +1,12 @@
|
||||
import { CanonicalSlug, FilePath, ServerSlug, canonicalizeServer, resolveRelative } from "../../path"
|
||||
import {
|
||||
CanonicalSlug,
|
||||
FilePath,
|
||||
ServerSlug,
|
||||
canonicalizeServer,
|
||||
resolveRelative,
|
||||
} from "../../path"
|
||||
import { QuartzEmitterPlugin } from "../types"
|
||||
import path from 'path'
|
||||
import path from "path"
|
||||
|
||||
export const AliasRedirects: QuartzEmitterPlugin = () => ({
|
||||
name: "AliasRedirects",
|
||||
@ -24,7 +30,7 @@ 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 fp = (slug + ".html") as FilePath
|
||||
const redirUrl = resolveRelative(canonicalizeServer(slug), ogSlug)
|
||||
await emit({
|
||||
content: `
|
||||
@ -47,5 +53,5 @@ export const AliasRedirects: QuartzEmitterPlugin = () => ({
|
||||
}
|
||||
}
|
||||
return fps
|
||||
}
|
||||
},
|
||||
})
|
||||
|
@ -5,12 +5,12 @@ import path from "path"
|
||||
|
||||
export type ContentIndex = Map<CanonicalSlug, ContentDetails>
|
||||
export type ContentDetails = {
|
||||
title: string,
|
||||
links: CanonicalSlug[],
|
||||
tags: string[],
|
||||
content: string,
|
||||
date?: Date,
|
||||
description?: string,
|
||||
title: string
|
||||
links: CanonicalSlug[]
|
||||
tags: string[]
|
||||
content: string
|
||||
date?: Date
|
||||
description?: string
|
||||
}
|
||||
|
||||
interface Options {
|
||||
@ -31,7 +31,9 @@ function generateSiteMap(cfg: GlobalConfiguration, idx: ContentIndex): string {
|
||||
<loc>https://${base}/${slug}</loc>
|
||||
<lastmod>${content.date?.toISOString()}</lastmod>
|
||||
</url>`
|
||||
const urls = Array.from(idx).map(([slug, content]) => createURLEntry(slug, content)).join("")
|
||||
const urls = Array.from(idx)
|
||||
.map(([slug, content]) => createURLEntry(slug, content))
|
||||
.join("")
|
||||
return `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">${urls}</urlset>`
|
||||
}
|
||||
|
||||
@ -47,7 +49,9 @@ function generateRSSFeed(cfg: GlobalConfiguration, idx: ContentIndex): string {
|
||||
<pubDate>${content.date?.toUTCString()}</pubDate>
|
||||
</items>`
|
||||
|
||||
const items = Array.from(idx).map(([slug, content]) => createURLEntry(slug, content)).join("")
|
||||
const items = Array.from(idx)
|
||||
.map(([slug, content]) => createURLEntry(slug, content))
|
||||
.join("")
|
||||
return `<rss xmlns:atom="http://www.w3.org/2005/atom" version="2.0">
|
||||
<channel>
|
||||
<title>${cfg.pageTitle}</title>
|
||||
@ -71,14 +75,14 @@ export const ContentIndex: QuartzEmitterPlugin<Partial<Options>> = (opts) => {
|
||||
const slug = canonicalizeServer(file.data.slug!)
|
||||
const date = file.data.dates?.modified ?? new Date()
|
||||
if (opts?.includeEmptyFiles || (file.data.text && file.data.text !== "")) {
|
||||
linkIndex.set(slug, {
|
||||
title: file.data.frontmatter?.title!,
|
||||
links: file.data.links ?? [],
|
||||
tags: file.data.frontmatter?.tags ?? [],
|
||||
content: file.data.text ?? "",
|
||||
date: date,
|
||||
description: file.data.description ?? ""
|
||||
})
|
||||
linkIndex.set(slug, {
|
||||
title: file.data.frontmatter?.title!,
|
||||
links: file.data.links ?? [],
|
||||
tags: file.data.frontmatter?.tags ?? [],
|
||||
content: file.data.text ?? "",
|
||||
date: date,
|
||||
description: file.data.description ?? "",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +90,7 @@ export const ContentIndex: QuartzEmitterPlugin<Partial<Options>> = (opts) => {
|
||||
await emit({
|
||||
content: generateSiteMap(cfg, linkIndex),
|
||||
slug: "sitemap" as ServerSlug,
|
||||
ext: ".xml"
|
||||
ext: ".xml",
|
||||
})
|
||||
emitted.push("sitemap.xml" as FilePath)
|
||||
}
|
||||
@ -95,7 +99,7 @@ export const ContentIndex: QuartzEmitterPlugin<Partial<Options>> = (opts) => {
|
||||
await emit({
|
||||
content: generateRSSFeed(cfg, linkIndex),
|
||||
slug: "index" as ServerSlug,
|
||||
ext: ".xml"
|
||||
ext: ".xml",
|
||||
})
|
||||
emitted.push("index.xml" as FilePath)
|
||||
}
|
||||
@ -109,7 +113,7 @@ export const ContentIndex: QuartzEmitterPlugin<Partial<Options>> = (opts) => {
|
||||
delete content.description
|
||||
delete content.date
|
||||
return [slug, content]
|
||||
})
|
||||
}),
|
||||
)
|
||||
|
||||
await emit({
|
||||
|
@ -8,7 +8,9 @@ import { FilePath, canonicalizeServer } from "../../path"
|
||||
|
||||
export const ContentPage: QuartzEmitterPlugin<FullPageLayout> = (opts) => {
|
||||
if (!opts) {
|
||||
throw new Error("ContentPage must be initialized with options specifiying the components to use")
|
||||
throw new Error(
|
||||
"ContentPage must be initialized with options specifiying the components to use",
|
||||
)
|
||||
}
|
||||
|
||||
const { head: Head, header, beforeBody, pageBody: Content, left, right, footer: Footer } = opts
|
||||
@ -22,7 +24,7 @@ export const ContentPage: QuartzEmitterPlugin<FullPageLayout> = (opts) => {
|
||||
},
|
||||
async emit(_contentDir, cfg, content, resources, emit): Promise<FilePath[]> {
|
||||
const fps: FilePath[] = []
|
||||
const allFiles = content.map(c => c[1].data)
|
||||
const allFiles = content.map((c) => c[1].data)
|
||||
for (const [tree, file] of content) {
|
||||
const slug = canonicalizeServer(file.data.slug!)
|
||||
const externalResources = pageResources(slug, resources)
|
||||
@ -32,17 +34,12 @@ export const ContentPage: QuartzEmitterPlugin<FullPageLayout> = (opts) => {
|
||||
cfg,
|
||||
children: [],
|
||||
tree,
|
||||
allFiles
|
||||
allFiles,
|
||||
}
|
||||
|
||||
const content = renderPage(
|
||||
slug,
|
||||
componentData,
|
||||
opts,
|
||||
externalResources
|
||||
)
|
||||
const content = renderPage(slug, componentData, opts, externalResources)
|
||||
|
||||
const fp = file.data.slug + ".html" as FilePath
|
||||
const fp = (file.data.slug + ".html") as FilePath
|
||||
await emit({
|
||||
content,
|
||||
slug: file.data.slug!,
|
||||
@ -52,6 +49,6 @@ export const ContentPage: QuartzEmitterPlugin<FullPageLayout> = (opts) => {
|
||||
fps.push(fp)
|
||||
}
|
||||
return fps
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -24,20 +24,28 @@ export const FolderPage: QuartzEmitterPlugin<FullPageLayout> = (opts) => {
|
||||
},
|
||||
async emit(_contentDir, cfg, content, resources, emit): Promise<FilePath[]> {
|
||||
const fps: FilePath[] = []
|
||||
const allFiles = content.map(c => c[1].data)
|
||||
const allFiles = content.map((c) => c[1].data)
|
||||
|
||||
const folders: Set<CanonicalSlug> = new Set(allFiles.flatMap(data => {
|
||||
const slug = data.slug
|
||||
const folderName = path.dirname(slug ?? "") as CanonicalSlug
|
||||
if (slug && folderName !== "." && folderName !== "tags") {
|
||||
return [folderName]
|
||||
}
|
||||
return []
|
||||
}))
|
||||
const folders: Set<CanonicalSlug> = new Set(
|
||||
allFiles.flatMap((data) => {
|
||||
const slug = data.slug
|
||||
const folderName = path.dirname(slug ?? "") as CanonicalSlug
|
||||
if (slug && folderName !== "." && folderName !== "tags") {
|
||||
return [folderName]
|
||||
}
|
||||
return []
|
||||
}),
|
||||
)
|
||||
|
||||
const folderDescriptions: Record<string, ProcessedContent> = Object.fromEntries([...folders].map(folder => ([
|
||||
folder, defaultProcessedContent({ slug: joinSegments(folder, "index") as ServerSlug, frontmatter: { title: `Folder: ${folder}`, tags: [] } })
|
||||
])))
|
||||
const folderDescriptions: Record<string, ProcessedContent> = Object.fromEntries(
|
||||
[...folders].map((folder) => [
|
||||
folder,
|
||||
defaultProcessedContent({
|
||||
slug: joinSegments(folder, "index") as ServerSlug,
|
||||
frontmatter: { title: `Folder: ${folder}`, tags: [] },
|
||||
}),
|
||||
]),
|
||||
)
|
||||
|
||||
for (const [tree, file] of content) {
|
||||
const slug = canonicalizeServer(file.data.slug!)
|
||||
@ -56,17 +64,12 @@ export const FolderPage: QuartzEmitterPlugin<FullPageLayout> = (opts) => {
|
||||
cfg,
|
||||
children: [],
|
||||
tree,
|
||||
allFiles
|
||||
allFiles,
|
||||
}
|
||||
|
||||
const content = renderPage(
|
||||
slug,
|
||||
componentData,
|
||||
opts,
|
||||
externalResources
|
||||
)
|
||||
const content = renderPage(slug, componentData, opts, externalResources)
|
||||
|
||||
const fp = file.data.slug! + ".html" as FilePath
|
||||
const fp = (file.data.slug! + ".html") as FilePath
|
||||
await emit({
|
||||
content,
|
||||
slug: file.data.slug!,
|
||||
@ -76,6 +79,6 @@ export const FolderPage: QuartzEmitterPlugin<FullPageLayout> = (opts) => {
|
||||
fps.push(fp)
|
||||
}
|
||||
return fps
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
export { ContentPage } from './contentPage'
|
||||
export { TagPage } from './tagPage'
|
||||
export { FolderPage } from './folderPage'
|
||||
export { ContentIndex } from './contentIndex'
|
||||
export { AliasRedirects } from './aliases'
|
||||
export { ContentPage } from "./contentPage"
|
||||
export { TagPage } from "./tagPage"
|
||||
export { FolderPage } from "./folderPage"
|
||||
export { ContentIndex } from "./contentIndex"
|
||||
export { AliasRedirects } from "./aliases"
|
||||
|
@ -23,12 +23,18 @@ export const TagPage: QuartzEmitterPlugin<FullPageLayout> = (opts) => {
|
||||
},
|
||||
async emit(_contentDir, cfg, content, resources, emit): Promise<FilePath[]> {
|
||||
const fps: FilePath[] = []
|
||||
const allFiles = content.map(c => c[1].data)
|
||||
const allFiles = content.map((c) => c[1].data)
|
||||
|
||||
const tags: Set<string> = new Set(allFiles.flatMap(data => data.frontmatter?.tags ?? []))
|
||||
const tagDescriptions: Record<string, ProcessedContent> = Object.fromEntries([...tags].map(tag => ([
|
||||
tag, defaultProcessedContent({ slug: `tags/${tag}/index` as ServerSlug, frontmatter: { title: `Tag: ${tag}`, tags: [] } })
|
||||
])))
|
||||
const tags: Set<string> = new Set(allFiles.flatMap((data) => data.frontmatter?.tags ?? []))
|
||||
const tagDescriptions: Record<string, ProcessedContent> = Object.fromEntries(
|
||||
[...tags].map((tag) => [
|
||||
tag,
|
||||
defaultProcessedContent({
|
||||
slug: `tags/${tag}/index` as ServerSlug,
|
||||
frontmatter: { title: `Tag: ${tag}`, tags: [] },
|
||||
}),
|
||||
]),
|
||||
)
|
||||
|
||||
for (const [tree, file] of content) {
|
||||
const slug = file.data.slug!
|
||||
@ -50,17 +56,12 @@ export const TagPage: QuartzEmitterPlugin<FullPageLayout> = (opts) => {
|
||||
cfg,
|
||||
children: [],
|
||||
tree,
|
||||
allFiles
|
||||
allFiles,
|
||||
}
|
||||
|
||||
const content = renderPage(
|
||||
slug,
|
||||
componentData,
|
||||
opts,
|
||||
externalResources
|
||||
)
|
||||
const content = renderPage(slug, componentData, opts, externalResources)
|
||||
|
||||
const fp = file.data.slug + ".html" as FilePath
|
||||
const fp = (file.data.slug + ".html") as FilePath
|
||||
await emit({
|
||||
content,
|
||||
slug: file.data.slug!,
|
||||
@ -70,6 +71,6 @@ export const TagPage: QuartzEmitterPlugin<FullPageLayout> = (opts) => {
|
||||
fps.push(fp)
|
||||
}
|
||||
return fps
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user