This commit is contained in:
Amarjeet Singh Rai 2025-11-16 14:19:11 +00:00
parent 119e71d06e
commit 1275fdf1a2
No known key found for this signature in database
5 changed files with 8 additions and 17 deletions

View File

@ -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](<https://en.wikipedia.org/wiki/Glob_(programming)>) 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.

View File

@ -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.

View File

@ -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,

View File

@ -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"],
],

View File

@ -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("/")