diff --git a/pages/blog/[blog].js b/pages/blog/[blog].js index 1b1e85e..dc7fb63 100644 --- a/pages/blog/[blog].js +++ b/pages/blog/[blog].js @@ -12,6 +12,8 @@ import styles from "../../style/bloga.module.css" import { ANDROID_URL, IOS_URL } from "../../constants" import appStorePic from "../../public/images/other/app-store-fr.png" import googlePlayPic from "../../public/images/other/google-play-fr.png" +import { parse } from "date-fns" +import { fr } from "date-fns/locale" const Blog = ({ mdxSource, data }) => { const [showPopup, setShowPopup] = useState(false) @@ -89,6 +91,18 @@ export async function getStaticProps({ params }) { const fileContents = fs.readFileSync(filePath, "utf-8") const { content, data } = matter(fileContents) const mdxSource = await serialize(content) + + const articleDate = parse(data.date, "MMMM d, yyyy", new Date(), { + locale: fr, + }) + + const currentDate = new Date() + + if (articleDate >= currentDate) { + return { + notFound: true, + } + } return { props: { mdxSource, diff --git a/pages/blog/index.js b/pages/blog/index.js index 21fff7e..07933c8 100644 --- a/pages/blog/index.js +++ b/pages/blog/index.js @@ -7,6 +7,8 @@ import Head from "next/head" import Navigation, { DownloadPopup } from "../../components/Navigation" import Footer from "../../components/Footer" import BlogCard from "../../components/BlogCard" +import { parse } from "date-fns" +import { fr } from "date-fns/locale" const Index = ({ posts }) => { const [showPopup, setShowPopup] = useState(false) @@ -27,6 +29,7 @@ const Index = ({ posts }) => {