Skip to content

Commit

Permalink
feat(dates): allow configurable default timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
baodrate committed Dec 13, 2024
1 parent 28f07b0 commit 93de138
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ This part of the configuration concerns anything that can affect the whole site.
- `{ provider: 'cabin' }` or `{ provider: 'cabin', host: 'https://cabin.example.com' }` (custom domain): use [Cabin](https://withcabin.com);
- `{provider: 'clarity', projectId: '<your-clarity-id-code' }`: use [Microsoft clarity](https://clarity.microsoft.com/). The project id can be found on top of the overview page.
- `locale`: used for [[i18n]] and date formatting
- `timezone`: timezone for interpreting dates (IANA format), when not specified in the datetime string; defaults to the system's local zone.
- `baseUrl`: this is used for sitemaps and RSS feeds that require an absolute URL to know where the canonical 'home' of your site lives. This is normally the deployed URL of your site (e.g. `quartz.jzhao.xyz` for this site). Do not include the protocol (i.e. `https://`) or any leading or trailing slashes.
- 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.
Expand Down
1 change: 1 addition & 0 deletions quartz/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ async function buildQuartz(argv: Argv, mut: Mutex, clientRefresh: () => void) {

LuxonSettings.throwOnInvalid = true
LuxonSettings.defaultLocale = cfg.configuration.locale
if (cfg.configuration.timezone) LuxonSettings.defaultZone = cfg.configuration.timezone

const pluginCount = Object.values(cfg.plugins).flat().length
const pluginNames = (key: "transformers" | "filters" | "emitters") =>
Expand Down
6 changes: 6 additions & 0 deletions quartz/cfg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ export interface GlobalConfiguration {
* Region Codes: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
*/
locale: ValidLocale
/**
* The default timezone when handling dates.
* Valid options are "system" (default), "utc", an IANA string, or a UTC offset
* https://moment.github.io/luxon/#/zones?id=specifying-a-zone
*/
timezone?: "system" | string
}

export interface QuartzConfig {
Expand Down

0 comments on commit 93de138

Please sign in to comment.