mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-31 00:34:05 -06:00
feat(dates): allow configurable default timezone
This commit is contained in:
parent
5f6788cada
commit
0b7dafd852
@ -12,6 +12,7 @@ This plugin determines the created, modified, and published dates for a document
|
|||||||
This plugin accepts the following configuration options:
|
This plugin accepts the following configuration options:
|
||||||
|
|
||||||
- `priority`: The data sources to consult for date information. Highest priority first. Possible values are `"frontmatter"`, `"git"`, and `"filesystem"`. Defaults to `["frontmatter", "git", "filesystem"]`.
|
- `priority`: The data sources to consult for date information. Highest priority first. Possible values are `"frontmatter"`, `"git"`, and `"filesystem"`. Defaults to `["frontmatter", "git", "filesystem"]`.
|
||||||
|
- `defaultTimezone`: The timezone that is assumed (IANA format, e.g. `Africa/Algiers`) when the datetime frontmatter properties do not contain offsets/timezones. Defaults to `system`: the system's local timezone.
|
||||||
|
|
||||||
> [!warning]
|
> [!warning]
|
||||||
> If you rely on `git` for dates, make sure `defaultDateType` is set to `modified` in `quartz.config.ts`.
|
> If you rely on `git` for dates, make sure `defaultDateType` is set to `modified` in `quartz.config.ts`.
|
||||||
|
|||||||
@ -7,10 +7,17 @@ import chalk from "chalk"
|
|||||||
|
|
||||||
export interface Options {
|
export interface Options {
|
||||||
priority: ("frontmatter" | "git" | "filesystem")[]
|
priority: ("frontmatter" | "git" | "filesystem")[]
|
||||||
|
/**
|
||||||
|
* The default timezone used when parsing datetime strings which lack an offset/timezone
|
||||||
|
* Valid options are "system" (default), "utc", an IANA string, or a UTC offset
|
||||||
|
* https://moment.github.io/luxon/#/zones?id=specifying-a-zone
|
||||||
|
*/
|
||||||
|
defaultTimezone: "system" | string
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultOptions: Options = {
|
const defaultOptions: Options = {
|
||||||
priority: ["frontmatter", "git", "filesystem"],
|
priority: ["frontmatter", "git", "filesystem"],
|
||||||
|
defaultTimezone: "system",
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseDateString(
|
function parseDateString(
|
||||||
@ -55,8 +62,9 @@ function parseDateString(
|
|||||||
|
|
||||||
export const CreatedModifiedDate: QuartzTransformerPlugin<Partial<Options>> = (userOpts) => {
|
export const CreatedModifiedDate: QuartzTransformerPlugin<Partial<Options>> = (userOpts) => {
|
||||||
const opts = { ...defaultOptions, ...userOpts }
|
const opts = { ...defaultOptions, ...userOpts }
|
||||||
const parseOpts = {
|
const parseOpts: DateTimeOptions = {
|
||||||
setZone: true,
|
setZone: true,
|
||||||
|
zone: opts.defaultTimezone,
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
name: "CreatedModifiedDate",
|
name: "CreatedModifiedDate",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user