1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-21 07:21:17 -04:00

prevent more hydration mismatches

This commit is contained in:
2022-04-21 12:45:39 -04:00
parent 54c662c1f2
commit 05469218b1
4 changed files with 5 additions and 4 deletions

View File

@@ -93,7 +93,7 @@ const Footer = ({ ...rest }: FooterProps) => (
<NextLink href="/previously/" prefetch={false} passHref={true}> <NextLink href="/previously/" prefetch={false} passHref={true}>
<Link title="Previously on...">2001</Link> <Link title="Previously on...">2001</Link>
</NextLink>{" "} </NextLink>{" "}
{new Date().getFullYear()}. {new Date(process.env.NEXT_PUBLIC_RELEASE_DATE).getUTCFullYear()}.
</div> </div>
<div> <div>

View File

@@ -2,7 +2,7 @@
export const NOTES_DIR = "./notes"; export const NOTES_DIR = "./notes";
// normalize the timestamp saved when building/deploying (see next.config.js) and fall back to right now: // normalize the timestamp saved when building/deploying (see next.config.js) and fall back to right now:
export const RELEASE_DATE = new Date(process.env.RELEASE_DATE ?? Date.now()).toISOString(); export const RELEASE_DATE = new Date(process.env.NEXT_PUBLIC_RELEASE_DATE ?? Date.now()).toISOString();
// detect current backend environment // detect current backend environment
export const IS_PROD = process.env.NEXT_PUBLIC_VERCEL_ENV === "production"; export const IS_PROD = process.env.NEXT_PUBLIC_VERCEL_ENV === "production";

View File

@@ -9,6 +9,7 @@ import { compiler } from "markdown-to-jsx";
import removeMarkdown from "remove-markdown"; import removeMarkdown from "remove-markdown";
import sanitizeHtml from "sanitize-html"; import sanitizeHtml from "sanitize-html";
import readingTime from "reading-time"; import readingTime from "reading-time";
import { formatDateISO } from "./format-date";
import { baseUrl } from "../config"; import { baseUrl } from "../config";
import { NOTES_DIR } from "../config/constants"; import { NOTES_DIR } from "../config/constants";
@@ -56,7 +57,7 @@ export const getNoteData = (slug: string): Omit<NoteType, "source"> & { content:
htmlTitle, htmlTitle,
slug, slug,
permalink: urlJoin(baseUrl, "notes", slug, "/"), permalink: urlJoin(baseUrl, "notes", slug, "/"),
date: new Date(data.date).toISOString(), // validate/normalize the date string provided from front matter date: formatDateISO(data.date), // validate/normalize the date string provided from front matter
readingMins: Math.ceil(readingTime(content).minutes), readingMins: Math.ceil(readingTime(content).minutes),
}, },
content, content,

View File

@@ -24,7 +24,7 @@ module.exports = (phase, { defaultConfig }) => {
productionBrowserSourceMaps: true, productionBrowserSourceMaps: true,
env: { env: {
// freeze build timestamp for when serverless pages need a "last updated" date: // freeze build timestamp for when serverless pages need a "last updated" date:
RELEASE_DATE: new Date().toISOString(), NEXT_PUBLIC_RELEASE_DATE: new Date().toISOString(),
// check if we're running locally via `next dev`: // check if we're running locally via `next dev`:
IS_DEV_SERVER: phase === PHASE_DEVELOPMENT_SERVER, IS_DEV_SERVER: phase === PHASE_DEVELOPMENT_SERVER,
}, },