Skip to content

Commit

Permalink
contentIndex: optimize non-RSS feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
bfahrenfort committed Nov 13, 2024
1 parent d3c386c commit bda8569
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions quartz/plugins/emitters/contentIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
Entry,
defaultFeed,
compareTreeNodes,
isContentDetails,
} from "./contentIndex/indexTree"
import DepGraph from "../../depgraph"
import chalk from "chalk"
Expand All @@ -39,7 +40,7 @@ export type ContentDetails = {
date?: Date
description?: string
slug?: FullSlug
noRSS: boolean
noRSS?: boolean
}

interface Options {
Expand Down Expand Up @@ -70,9 +71,7 @@ function generateSiteMap(cfg: GlobalConfiguration, idx: ContentIndex): string {
<loc>https://${joinSegments(base, encodeURI(simplifySlug(content.slug!)))}</loc>
${content.date && `<lastmod>${content.date.toISOString()}</lastmod>`}
</url>`
let urls = (idx.spread().filter((e) => typeof e != "string") as ContentDetails[])
.map((e) => createURLEntry(e))
.join("")
let urls = (idx.spread() as ContentDetails[]).map((e) => createURLEntry(e)).join("")
return `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">${urls}
</urlset>`
}
Expand Down Expand Up @@ -261,19 +260,18 @@ export const ContentIndex: QuartzEmitterPlugin<Partial<Options>> = (opts) => {
// Generate ContentIndex
const fp = joinSegments("static", "contentIndex") as FullSlug
const simplifiedIndex = Object.fromEntries(
(indexTree.spread().filter((e) => typeof e != "string") as ContentDetails[]).map(
(content) => {
// remove description and from content index as nothing downstream
// actually uses it. we only keep it in the index as we need it
// for the RSS feed
delete content.description
delete content.date

var slug = content.slug
delete content.slug
return [slug, content]
},
),
(indexTree.spread() as ContentDetails[]).map((content) => {
// remove description and from content index as nothing downstream
// actually uses it. we only keep it in the index as we need it
// for the RSS feed
delete content.description
delete content.date
delete content.noRSS

var slug = content.slug
delete content.slug
return [slug, content]
}),
)
emitted.push(
write({
Expand Down

0 comments on commit bda8569

Please sign in to comment.