diff --git a/docs/configuration.md b/docs/configuration.md index 1622da6fa..2e904e9e7 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -40,6 +40,7 @@ This part of the configuration concerns anything that can affect the whole site. - 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. - `defaultDateType`: whether to use created, modified, or published as the default date to display on pages and page listings. + - Can be a list (e.g. `["created", "modified"]`) to define fallbacks (highest priority first). - `theme`: configure how the site looks. - `cdnCaching`: If `true` (default), use Google CDN to cache the fonts. This will generally will be faster. Disable (`false`) this if you want Quartz to download the fonts to be self-contained. - `typography`: what fonts to use. Any font available on [Google Fonts](https://fonts.google.com/) works here. diff --git a/quartz/cfg.ts b/quartz/cfg.ts index 135f58499..0c755b741 100644 --- a/quartz/cfg.ts +++ b/quartz/cfg.ts @@ -56,7 +56,7 @@ export interface GlobalConfiguration { /** Glob patterns to not search */ ignorePatterns: string[] /** Whether to use created, modified, or published as the default type of date */ - defaultDateType: ValidDateType + defaultDateType: ValidDateType | ValidDateType[] /** Base URL to use for CNAME files, sitemaps, and RSS feeds that require an absolute URL. * Quartz will avoid using this as much as possible and use relative URLs most of the time */ diff --git a/quartz/components/Date.tsx b/quartz/components/Date.tsx index a75d02859..783a86f01 100644 --- a/quartz/components/Date.tsx +++ b/quartz/components/Date.tsx @@ -16,7 +16,8 @@ export function getDate(cfg: GlobalConfiguration, data: QuartzPluginData): DateT `Field 'defaultDateType' was not set in the configuration object of quartz.config.ts. See https://quartz.jzhao.xyz/configuration#general-configuration for more details.`, ) } - return data.dates?.[cfg.defaultDateType] + const types = cfg.defaultDateType instanceof Array ? cfg.defaultDateType : [cfg.defaultDateType] + return types.map((p) => data.dates?.[p]).find((p) => p != null) } export function formatDate(d: DateTime, locale: ValidLocale = "en-US"): string {