From e277ed5c307cd263b0f07dfece45946c3fe195d9 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Thu, 28 Dec 2023 08:54:04 -0800 Subject: [PATCH] fix: use joinSegment instead of joining via slash in sitemap (closes #658) --- quartz/plugins/emitters/contentIndex.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/quartz/plugins/emitters/contentIndex.ts b/quartz/plugins/emitters/contentIndex.ts index c5170c6..bc4c6c3 100644 --- a/quartz/plugins/emitters/contentIndex.ts +++ b/quartz/plugins/emitters/contentIndex.ts @@ -2,7 +2,7 @@ import { Root } from "hast" import { GlobalConfiguration } from "../../cfg" import { getDate } from "../../components/Date" import { escapeHTML } from "../../util/escape" -import { FilePath, FullSlug, SimpleSlug, simplifySlug } from "../../util/path" +import { FilePath, FullSlug, SimpleSlug, joinSegments, simplifySlug } from "../../util/path" import { QuartzEmitterPlugin } from "../types" import { toHtml } from "hast-util-to-html" import path from "path" @@ -37,7 +37,7 @@ const defaultOptions: Options = { function generateSiteMap(cfg: GlobalConfiguration, idx: ContentIndex): string { const base = cfg.baseUrl ?? "" const createURLEntry = (slug: SimpleSlug, content: ContentDetails): string => ` - https://${base}/${encodeURI(slug)} + https://${joinSegments(base, encodeURI(slug))} ${content.date?.toISOString()} ` const urls = Array.from(idx) @@ -52,8 +52,8 @@ function generateRSSFeed(cfg: GlobalConfiguration, idx: ContentIndex, limit?: nu const createURLEntry = (slug: SimpleSlug, content: ContentDetails): string => ` ${escapeHTML(content.title)} - ${root}/${encodeURI(slug)} - ${root}/${encodeURI(slug)} + ${joinSegments(root, encodeURI(slug))} + ${joinSegments(root, encodeURI(slug))} ${content.richContent ?? content.description} ${content.date?.toUTCString()} `