Skip to content

Commit

Permalink
BOOM fixed it - removed dependency on 'date-dns'
Browse files Browse the repository at this point in the history
  • Loading branch information
bradystroud committed Apr 14, 2024
1 parent b386aaf commit a9d7c4b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
8 changes: 6 additions & 2 deletions components/posts/reviews.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";
import Link from "next/link";
import { BsArrowRight, BsPinMap } from "react-icons/bs";
import { format } from "date-fns";

export const Reviews = ({ data }) => {
return (
Expand All @@ -10,8 +9,13 @@ export const Reviews = ({ data }) => {
const post = reviewData.node;
const date = new Date(post.date);
let formattedDate = "";

if (!isNaN(date.getTime())) {
formattedDate = format(date, "MMM dd, yyyy");
formattedDate = date.toLocaleDateString("en-US", {
day: "numeric",
month: "long",
year: "numeric",
});
}
return (
<Link
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"dependencies": {
"@headlessui/react": "1.7.18",
"@tailwindcss/typography": "^0.5.8",
"date-fns": "^3.6.0",
"next": "^14.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
8 changes: 6 additions & 2 deletions pages/reviews/[filename].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useTina } from "tinacms/dist/react";
import { Layout } from "../../components/layout";
import { Section } from "../../components/util/section";
import { Container } from "../../components/util/container";
import format from "date-fns/format";
import { TinaMarkdown } from "tinacms/dist/rich-text";
import { InferGetStaticPropsType } from "next";

Expand All @@ -20,8 +19,13 @@ export default function ReviewPage(

const date = new Date(data.review.date);
let formattedDate = "";

if (!isNaN(date.getTime())) {
formattedDate = format(date, "MMM dd, yyyy");
formattedDate = date.toLocaleDateString("en-US", {
day: "numeric",
month: "long",
year: "numeric",
});
}

if (data && data.review) {
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4674,11 +4674,6 @@ [email protected], date-fns@^2.21.1:
dependencies:
"@babel/runtime" "^7.21.0"

date-fns@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-3.6.0.tgz#f20ca4fe94f8b754951b24240676e8618c0206bf"
integrity sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==

date-format@^4.0.14:
version "4.0.14"
resolved "https://registry.yarnpkg.com/date-format/-/date-format-4.0.14.tgz#7a8e584434fb169a521c8b7aa481f355810d9400"
Expand Down

0 comments on commit a9d7c4b

Please sign in to comment.