From 1275fdf1a2bc277fa16c075e42cec470b1809bbc Mon Sep 17 00:00:00 2001 From: Amarjeet Singh Rai Date: Sun, 16 Nov 2025 14:19:11 +0000 Subject: [PATCH] cleanup --- docs/configuration.md | 2 +- quartz/cfg.ts | 2 +- quartz/plugins/emitters/assets.ts | 8 ++++---- quartz/util/path.test.ts | 2 +- quartz/util/path.ts | 11 +---------- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index bccef0b08..bfd4ef745 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -41,7 +41,7 @@ This part of the configuration concerns anything that can affect the whole site. - This should also include the subpath if you are [[hosting]] on GitHub pages without a custom domain. For example, if my repository is `jackyzha0/quartz`, GitHub pages would deploy to `https://jackyzha0.github.io/quartz` and the `baseUrl` would be `jackyzha0.github.io/quartz`. - Note that Quartz 4 will avoid using this as much as possible and use relative URLs whenever it can to make sure your site works no matter _where_ you end up actually deploying it. - `ignorePatterns`: a list of [glob]() patterns that Quartz should ignore and not search through when looking for files inside the `content` folder. See [[private pages]] for more details. -- `lowercasePaths`: whether to convert all generated paths (URLs) to lowercase. When set to `true`, a file named `MyFile.md` will be available at `/myfile` instead of `/MyFile`. This also applies to tags but not aliases. Default is `false`. +- `lowercasePaths`: whether to convert all generated paths (URLs) to lowercase. When set to `true`, a file named `MyFile.md` will be available at `/myfile` instead of `/MyFile`. This also applies to tags but not aliases. - `defaultDateType`: whether to use created, modified, or published as the default date to display on pages and page listings. - `theme`: configure how the site looks. - `cdnCaching`: if `true` (default), use Google CDN to cache the fonts. This will generally be faster. Disable (`false`) this if you want Quartz to download the fonts to be self-contained. diff --git a/quartz/cfg.ts b/quartz/cfg.ts index 9984e4664..5cd009479 100644 --- a/quartz/cfg.ts +++ b/quartz/cfg.ts @@ -63,7 +63,7 @@ export interface GlobalConfiguration { /** Glob patterns to not search */ ignorePatterns: string[] /** Whether to convert all generated paths to lowercase (default: false) */ - lowercasePaths?: boolean + lowercasePaths: boolean /** Whether to use created, modified, or published as the default type of date */ defaultDateType: ValidDateType /** Base URL to use for CNAME files, sitemaps, and RSS feeds that require an absolute URL. diff --git a/quartz/plugins/emitters/assets.ts b/quartz/plugins/emitters/assets.ts index 2cb5a017a..854a45a7a 100644 --- a/quartz/plugins/emitters/assets.ts +++ b/quartz/plugins/emitters/assets.ts @@ -11,10 +11,10 @@ const filesToCopy = async (argv: Argv, cfg: QuartzConfig) => { return await glob("**", argv.directory, ["**/*.md", ...cfg.configuration.ignorePatterns]) } -const copyFile = async (argv: Argv, fp: FilePath, cfg: QuartzConfig) => { +const copyFile = async (argv: Argv, fp: FilePath, lowercasePaths: boolean) => { const src = joinSegments(argv.directory, fp) as FilePath - const name = slugifyFilePath(fp, undefined, cfg.configuration.lowercasePaths) + const name = slugifyFilePath(fp, undefined, lowercasePaths) const dest = joinSegments(argv.output, name) as FilePath // ensure dir exists @@ -31,7 +31,7 @@ export const Assets: QuartzEmitterPlugin = () => { async *emit({ argv, cfg }) { const fps = await filesToCopy(argv, cfg) for (const fp of fps) { - yield copyFile(argv, fp, cfg) + yield copyFile(argv, fp, cfg.configuration.lowercasePaths) } }, async *partialEmit(ctx, _content, _resources, changeEvents) { @@ -40,7 +40,7 @@ export const Assets: QuartzEmitterPlugin = () => { if (ext === ".md") continue if (changeEvent.type === "add" || changeEvent.type === "change") { - yield copyFile(ctx.argv, changeEvent.path, ctx.cfg) + yield copyFile(ctx.argv, changeEvent.path, ctx.cfg.configuration.lowercasePaths) } else if (changeEvent.type === "delete") { const name = slugifyFilePath( changeEvent.path, diff --git a/quartz/util/path.test.ts b/quartz/util/path.test.ts index 2c62e9a9d..c9727e98c 100644 --- a/quartz/util/path.test.ts +++ b/quartz/util/path.test.ts @@ -189,7 +189,7 @@ describe("transforms", () => { ["Tags/", "./tags/"], ["/Tags/", "./tags/"], ["Content/With Spaces", "./content/with-spaces"], - ["Content/With Spaces/Index", "./content/with-spaces/"], + ["Content/With Spaces/index", "./content/with-spaces/"], ["Content/With Spaces#And Anchor!", "./content/with-spaces#and-anchor"], ["MixedCase/File.md", "./mixedcase/file"], ], diff --git a/quartz/util/path.ts b/quartz/util/path.ts index b62b5a282..e1097fa07 100644 --- a/quartz/util/path.ts +++ b/quartz/util/path.ts @@ -97,16 +97,7 @@ export function simplifySlug(fp: FullSlug): SimpleSlug { export function transformInternalLink(link: string, lowercase?: boolean): RelativeURL { let [fplike, anchor] = splitAnchor(decodeURI(link)) - // If lowercase is enabled, check for folder path in a case-insensitive way - const folderPath = lowercase - ? fplike.endsWith("/") || - fplike.toLowerCase().endsWith("/index") || - fplike.toLowerCase().endsWith("/index.md") || - fplike.toLowerCase().endsWith("/index.html") || - fplike.toLowerCase() === "index" || - fplike.toLowerCase() === "index.md" || - fplike.toLowerCase() === "index.html" - : isFolderPath(fplike) + const folderPath = isFolderPath(fplike) let segments = fplike.split("/").filter((x) => x.length > 0) let prefix = segments.filter(isRelativeSegment).join("/") let fp = segments.filter((seg) => !isRelativeSegment(seg) && seg !== "").join("/")