Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
"@headlessui/react": "^2.2.0",
"@heroicons/react": "^2.2.0",
"@icons-pack/react-simple-icons": "^12.3.0",
"@js-temporal/polyfill": "^0.4.4",
"@jsdevtools/rehype-url-inspector": "^2.0.2",
"@octokit/core": "^6.1.4",
"@shikijs/transformers": "^3.2.1",
"@sindresorhus/slugify": "^2.2.1",
"@wpengine/atlas-next": "^2.0.1",
"date-fns": "^4.1.0",
"date-fns-tz": "^3.2.0",
"downshift": "^9.0.9",
"feed": "^4.2.2",
"graphql": "^16.10.0",
Expand Down
29 changes: 12 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/lib/feed.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { env } from "node:process";
import { URL } from "node:url";
import { gql } from "@apollo/client";
import { Temporal } from "@js-temporal/polyfill";
import { format } from "date-fns-tz";
import { Feed } from "feed";

const SITE_URL = env.NEXT_PUBLIC_SITE_URL;
Expand Down Expand Up @@ -56,9 +56,9 @@ export function createFeed({ feed_data, last_modified }) {
language: "en",
image: new URL("/favicon-192x192.png", SITE_URL).href,
favicon: new URL("/favicon-32x32.png", SITE_URL).href,
copyright: Temporal.Now.plainDateISO(
feed_data.generalSettings.timezone,
).year.toString(),
copyright: format(new Date(), "yyyy", {
timeZone: feed_data.generalSettings.timezone,
}),
updated: new Date(last_modified.toString()),
feedLinks: {
json: new URL("/api/feeds/feed.json", SITE_URL).href,
Expand Down
13 changes: 5 additions & 8 deletions src/pages/api/feeds/[feed-type].js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createHash } from "node:crypto";
import { getApolloClient } from "@faustwp/core/dist/mjs/client";
import { Temporal } from "@js-temporal/polyfill";
import { parseISO, compareAsc } from "date-fns"; // Replaced Temporal with date-fns
import { StatusCodes, getReasonPhrase } from "http-status-codes";
import { FEED_QUERY, createFeed } from "@/lib/feed";

Expand All @@ -18,12 +18,9 @@ export default async function HandleFeeds(req, res) {
query: FEED_QUERY,
});

const last_modified = Temporal.PlainDateTime.from(
const last_modified = parseISO(
feed_data.last_modified.nodes[0].modifiedGmt,
{
overflow: "constrain",
},
);
); // Replaced Temporal.PlainDateTime.from

// Create feed
const feed = createFeed({ feed_data, last_modified });
Expand Down Expand Up @@ -75,14 +72,14 @@ export default async function HandleFeeds(req, res) {
);
res.setHeader("Content-Type", resp.content_type);
res.setHeader("ETag", etag_for_body);
res.setHeader("Last-Modified", last_modified.toString());
res.setHeader("Last-Modified", last_modified.toUTCString()); // Adjusted to use Date's toUTCString()

if (
// Checks if the `if_none_match` header matches current response' etag
if_none_match === etag_for_body ||
// Checks `if_modified_since` is after `last_modified`
(if_modified_since &&
Temporal.PlainDateTime.compare(last_modified, if_modified_since) < 0)
compareAsc(last_modified, new Date(if_modified_since)) < 0) // Replaced Temporal.PlainDateTime.compare
) {
res.status(StatusCodes.NOT_MODIFIED);
res.end();
Expand Down