Change site default time zone to fix RSS issue
This commit is contained in:
parent
8a48f677f6
commit
af04f61821
@ -20,6 +20,8 @@ const figoptions = {
|
||||
figcaption: true,
|
||||
};
|
||||
|
||||
const timeZone = "America/Chicago";
|
||||
|
||||
export default async function (eleventyConfig) {
|
||||
// Helper Functions
|
||||
const multiReplace = (text, replacementTable) => {
|
||||
@ -30,6 +32,25 @@ export default async function (eleventyConfig) {
|
||||
return newText;
|
||||
};
|
||||
|
||||
eleventyConfig.addDateParsing((dateValue) => {
|
||||
let localDate;
|
||||
if (dateValue instanceof Date) {
|
||||
// and YAML
|
||||
localDate = DateTime.fromJSDate(dateValue, { zone: "utc" }).setZone(
|
||||
timeZone,
|
||||
{ keepLocalTime: true },
|
||||
);
|
||||
} else if (typeof dateValue === "string") {
|
||||
localDate = DateTime.fromISO(dateValue, { zone: timeZone });
|
||||
}
|
||||
if (localDate?.isValid === false) {
|
||||
throw new Error(
|
||||
`Invalid \`date\` value (${dateValue}) is invalid for ${this.page.inputPath}: ${localDate.invalidReason}`,
|
||||
);
|
||||
}
|
||||
return localDate;
|
||||
});
|
||||
|
||||
// Collections
|
||||
eleventyConfig.addCollection("galleryImages", (collection) => {
|
||||
const galleries = collection.getAll()[0].data.galleries;
|
||||
@ -84,7 +105,6 @@ export default async function (eleventyConfig) {
|
||||
});
|
||||
|
||||
eleventyConfig.addFilter("htmlDateString", (dateObj) => {
|
||||
// dateObj input: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
|
||||
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat("yyyy-LL-dd");
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user