1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-09-18 13:25:32 -04:00

clean up remaining NEXT_PUBLIC_ environment variables

This commit is contained in:
2025-04-13 16:28:00 -04:00
parent f08aa16862
commit b60fbcc15c
21 changed files with 137 additions and 117 deletions

View File

@@ -1,8 +1,8 @@
import { env } from "../../lib/env";
import { JsonLd } from "react-schemaorg";
import PageTitle from "../../components/PageTitle";
import Video from "../../components/Video";
import { addMetadata } from "../../lib/helpers/metadata";
import { BASE_URL } from "../../lib/config/constants";
import type { VideoObject } from "schema-dts";
import mp4 from "./birthday.mp4";
@@ -26,9 +26,9 @@ const Page = () => {
"@type": "VideoObject",
name: metadata.title as string,
description: metadata.description as string,
contentUrl: `${BASE_URL}${webm}`,
thumbnailUrl: `${BASE_URL}${thumbnail.src}`,
embedUrl: `${BASE_URL}/birthday`,
contentUrl: `${env.NEXT_PUBLIC_BASE_URL}${webm}`,
thumbnailUrl: `${env.NEXT_PUBLIC_BASE_URL}${thumbnail.src}`,
embedUrl: `${env.NEXT_PUBLIC_BASE_URL}/birthday`,
uploadDate: "1996-02-06T00:00:00Z",
duration: "PT6M10S",
}}

View File

@@ -1,9 +1,9 @@
import { env } from "../../lib/env";
import { JsonLd } from "react-schemaorg";
import PageTitle from "../../components/PageTitle";
import Link from "../../components/Link";
import Video from "../../components/Video";
import { addMetadata } from "../../lib/helpers/metadata";
import { BASE_URL } from "../../lib/config/constants";
import type { VideoObject } from "schema-dts";
import webm from "./convention.webm";
@@ -28,9 +28,9 @@ const Page = () => {
"@type": "VideoObject",
name: metadata.title as string,
description: metadata.description as string,
contentUrl: `${BASE_URL}${webm}`,
thumbnailUrl: `${BASE_URL}${thumbnail.src}`,
embedUrl: `${BASE_URL}/hillary`,
contentUrl: `${env.NEXT_PUBLIC_BASE_URL}${webm}`,
thumbnailUrl: `${env.NEXT_PUBLIC_BASE_URL}${thumbnail.src}`,
embedUrl: `${env.NEXT_PUBLIC_BASE_URL}/hillary`,
uploadDate: "2016-07-25T00:00:00Z",
duration: "PT1M51S",
}}

View File

@@ -1,3 +1,4 @@
import { env } from "../lib/env";
import { JsonLd } from "react-schemaorg";
import { Analytics } from "@vercel/analytics/next";
import clsx from "clsx";
@@ -7,7 +8,7 @@ import Footer from "../components/Footer";
import { SkipNavLink, SkipNavTarget } from "../components/SkipNav";
import { defaultMetadata } from "../lib/helpers/metadata";
import * as config from "../lib/config";
import { BASE_URL, MAX_WIDTH, SITE_LOCALE } from "../lib/config/constants";
import { MAX_WIDTH } from "../lib/config/constants";
import type { Metadata } from "next";
import type { Person, WebSite } from "schema-dts";
@@ -21,7 +22,7 @@ export const metadata: Metadata = defaultMetadata;
const RootLayout = ({ children }: Readonly<{ children: React.ReactNode }>) => {
return (
<html lang={SITE_LOCALE || "en-US"} suppressHydrationWarning>
<html lang={env.NEXT_PUBLIC_SITE_LOCALE} suppressHydrationWarning>
<head>
<ThemeScript />
@@ -29,12 +30,12 @@ const RootLayout = ({ children }: Readonly<{ children: React.ReactNode }>) => {
item={{
"@context": "https://schema.org",
"@type": "Person",
"@id": `${BASE_URL}/#person`,
"@id": `${env.NEXT_PUBLIC_BASE_URL}/#person`,
name: config.authorName,
url: BASE_URL,
image: [`${BASE_URL}/opengraph-image.jpg`],
url: env.NEXT_PUBLIC_BASE_URL,
image: [`${env.NEXT_PUBLIC_BASE_URL}/opengraph-image.jpg`],
sameAs: [
`${BASE_URL}`,
env.NEXT_PUBLIC_BASE_URL!,
`https://${config.authorSocial?.mastodon}`,
`https://github.com/${config.authorSocial?.github}`,
`https://bsky.app/profile/${config.authorSocial?.bluesky}`,
@@ -51,12 +52,12 @@ const RootLayout = ({ children }: Readonly<{ children: React.ReactNode }>) => {
item={{
"@context": "https://schema.org",
"@type": "WebSite",
"@id": `${BASE_URL}/#website`,
"@id": `${env.NEXT_PUBLIC_BASE_URL}/#website`,
name: config.siteName,
url: BASE_URL,
url: env.NEXT_PUBLIC_BASE_URL,
author: config.authorName,
description: config.description,
inLanguage: SITE_LOCALE,
inLanguage: env.NEXT_PUBLIC_SITE_LOCALE,
license: config.licenseUrl,
}}
/>

View File

@@ -1,9 +1,9 @@
import { env } from "../../lib/env";
import { JsonLd } from "react-schemaorg";
import PageTitle from "../../components/PageTitle";
import Link from "../../components/Link";
import Video from "../../components/Video";
import { addMetadata } from "../../lib/helpers/metadata";
import { BASE_URL } from "../../lib/config/constants";
import type { VideoObject } from "schema-dts";
import mp4 from "./leo.mp4";
@@ -28,9 +28,9 @@ const Page = () => {
"@type": "VideoObject",
name: metadata.title as string,
description: metadata.description as string,
contentUrl: `${BASE_URL}${webm}`,
thumbnailUrl: `${BASE_URL}${thumbnail.src}`,
embedUrl: `${BASE_URL}/leo`,
contentUrl: `${env.NEXT_PUBLIC_BASE_URL}${webm}`,
thumbnailUrl: `${env.NEXT_PUBLIC_BASE_URL}${thumbnail.src}`,
embedUrl: `${env.NEXT_PUBLIC_BASE_URL}/leo`,
uploadDate: "2007-05-10T00:00:00Z",
duration: "PT1M48S",
}}

View File

@@ -1,5 +1,5 @@
import { env } from "../lib/env";
import * as config from "../lib/config";
import { SITE_LOCALE } from "../lib/config/constants";
import type { MetadataRoute } from "next";
const manifest = (): MetadataRoute.Manifest => {
@@ -8,7 +8,7 @@ const manifest = (): MetadataRoute.Manifest => {
// eslint-disable-next-line camelcase
short_name: config.siteName,
description: config.description,
lang: SITE_LOCALE,
lang: env.NEXT_PUBLIC_SITE_LOCALE,
icons: [
{
src: "/icon.png",

View File

@@ -1,7 +1,7 @@
import { env } from "../../../lib/env";
import { connection } from "next/server";
import CountUp from "../../../components/CountUp";
import redis from "../../../lib/redis";
import { SITE_LOCALE } from "../../../lib/config/constants";
const HitCounter = async ({ slug }: { slug: string }) => {
await connection();
@@ -16,7 +16,7 @@ const HitCounter = async ({ slug }: { slug: string }) => {
// we have data!
return (
<span title={`${Intl.NumberFormat(SITE_LOCALE || "en-US").format(hits)} ${hits === 1 ? "view" : "views"}`}>
<span title={`${Intl.NumberFormat(env.NEXT_PUBLIC_SITE_LOCALE).format(hits)} ${hits === 1 ? "view" : "views"}`}>
<CountUp start={0} end={hits} delay={0} duration={1.5} />
</span>
);

View File

@@ -10,7 +10,7 @@ import HitCounter from "./counter";
import { getSlugs, getFrontMatter } from "../../../lib/helpers/posts";
import { addMetadata } from "../../../lib/helpers/metadata";
import * as config from "../../../lib/config";
import { BASE_URL, POSTS_DIR, SITE_LOCALE } from "../../../lib/config/constants";
import { POSTS_DIR } from "../../../lib/config/constants";
import { size as ogImageSize } from "./opengraph-image";
import type { Metadata } from "next";
import type { BlogPosting } from "schema-dts";
@@ -72,18 +72,18 @@ const Page = async ({ params }: { params: Promise<{ slug: string }> }) => {
url: frontmatter!.permalink,
image: {
"@type": "ImageObject",
contentUrl: `${BASE_URL}/${POSTS_DIR}/${frontmatter!.slug}/opengraph-image`,
contentUrl: `${env.NEXT_PUBLIC_BASE_URL}/${POSTS_DIR}/${frontmatter!.slug}/opengraph-image`,
width: `${ogImageSize.width}`,
height: `${ogImageSize.height}`,
},
keywords: frontmatter!.tags?.join(", "),
datePublished: frontmatter!.date,
dateModified: frontmatter!.date,
inLanguage: SITE_LOCALE,
inLanguage: env.NEXT_PUBLIC_SITE_LOCALE,
license: config.licenseUrl,
author: {
// defined in app/layout.tsx
"@id": `${BASE_URL}/#person`,
"@id": `${env.NEXT_PUBLIC_BASE_URL}/#person`,
},
}}
/>
@@ -111,7 +111,7 @@ const Page = async ({ params }: { params: Promise<{ slug: string }> }) => {
<div className={styles.metaItem}>
<Link
href={`https://github.com/${config.githubRepo}/blob/main/${POSTS_DIR}/${frontmatter!.slug}/index.mdx`}
href={`https://github.com/${env.NEXT_PUBLIC_GITHUB_REPO}/blob/main/${POSTS_DIR}/${frontmatter!.slug}/index.mdx`}
title={`Edit "${frontmatter!.title}" on GitHub`}
plain
className={styles.metaLink}
@@ -121,26 +121,23 @@ const Page = async ({ params }: { params: Promise<{ slug: string }> }) => {
</Link>
</div>
{/* only count hits on production site */}
{env.VERCEL_ENV === "production" ? (
<div
className={styles.metaItem}
style={{
// fix potential layout shift when number of hits loads
minWidth: "7em",
marginRight: 0,
}}
<div
className={styles.metaItem}
style={{
// fix potential layout shift when number of hits loads
minWidth: "7em",
marginRight: 0,
}}
>
<EyeIcon size="1.2em" className={styles.metaIcon} />
<Suspense
// when this loads, the component will count up from zero to the actual number of hits, so we can simply
// show a zero here as a "loading indicator"
fallback={<span>0</span>}
>
<EyeIcon size="1.2em" className={styles.metaIcon} />
<Suspense
// when this loads, the component will count up from zero to the actual number of hits, so we can simply
// show a zero here as a "loading indicator"
fallback={<span>0</span>}
>
<HitCounter slug={`${POSTS_DIR}/${frontmatter!.slug}`} />
</Suspense>
</div>
) : null}
<HitCounter slug={`${POSTS_DIR}/${frontmatter!.slug}`} />
</Suspense>
</div>
</div>
<h1 className={styles.title}>

View File

@@ -7,7 +7,6 @@ import Link from "../../components/Link";
import RelativeTime from "../../components/RelativeTime";
import { addMetadata } from "../../lib/helpers/metadata";
import * as config from "../../lib/config";
import { SITE_LOCALE } from "../../lib/config/constants";
import type { User } from "@octokit/graphql-schema";
import styles from "./page.module.css";
@@ -121,12 +120,12 @@ const Page = async () => {
<div className={styles.metaItem}>
<Link
href={`${repo!.url}/stargazers`}
title={`${Intl.NumberFormat(SITE_LOCALE || "en-US").format(repo!.stargazerCount)} ${repo!.stargazerCount === 1 ? "star" : "stars"}`}
title={`${Intl.NumberFormat(env.NEXT_PUBLIC_SITE_LOCALE).format(repo!.stargazerCount)} ${repo!.stargazerCount === 1 ? "star" : "stars"}`}
plain
className={styles.metaLink}
>
<StarIcon size="1.25em" className={styles.metaIcon} />
<span>{Intl.NumberFormat(SITE_LOCALE || "en-US").format(repo!.stargazerCount)}</span>
<span>{Intl.NumberFormat(env.NEXT_PUBLIC_SITE_LOCALE).format(repo!.stargazerCount)}</span>
</Link>
</div>
)}
@@ -135,12 +134,12 @@ const Page = async () => {
<div className={styles.metaItem}>
<Link
href={`${repo!.url}/network/members`}
title={`${Intl.NumberFormat(SITE_LOCALE || "en-US").format(repo!.forkCount)} ${repo!.forkCount === 1 ? "fork" : "forks"}`}
title={`${Intl.NumberFormat(env.NEXT_PUBLIC_SITE_LOCALE).format(repo!.forkCount)} ${repo!.forkCount === 1 ? "fork" : "forks"}`}
plain
className={styles.metaLink}
>
<GitForkIcon size="1.25em" className={styles.metaIcon} />
<span>{Intl.NumberFormat(SITE_LOCALE || "en-US").format(repo!.forkCount)}</span>
<span>{Intl.NumberFormat(env.NEXT_PUBLIC_SITE_LOCALE).format(repo!.forkCount)}</span>
</Link>
</div>
)}

View File

@@ -1,4 +1,4 @@
import { BASE_URL } from "../lib/config/constants";
import { env } from "../lib/env";
import type { MetadataRoute } from "next";
const robots = (): MetadataRoute.Robots => ({
@@ -8,7 +8,7 @@ const robots = (): MetadataRoute.Robots => ({
disallow: ["/api/", "/404", "/500"],
},
],
sitemap: `${BASE_URL}/sitemap.xml`,
sitemap: `${env.NEXT_PUBLIC_BASE_URL}/sitemap.xml`,
});
export default robots;

View File

@@ -1,7 +1,7 @@
import { env } from "../lib/env";
import path from "path";
import glob from "fast-glob";
import { getFrontMatter } from "../lib/helpers/posts";
import { BASE_URL, RELEASE_TIMESTAMP } from "../lib/config/constants";
import type { MetadataRoute } from "next";
const sitemap = async (): Promise<MetadataRoute.Sitemap> => {
@@ -9,9 +9,9 @@ const sitemap = async (): Promise<MetadataRoute.Sitemap> => {
const routes: MetadataRoute.Sitemap = [
{
// homepage
url: `${BASE_URL}`,
url: `${env.NEXT_PUBLIC_BASE_URL}`,
priority: 1.0,
lastModified: new Date(RELEASE_TIMESTAMP), // timestamp frozen when a new build is deployed
lastModified: new Date(),
},
];
@@ -30,7 +30,7 @@ const sitemap = async (): Promise<MetadataRoute.Sitemap> => {
).forEach((route) => {
routes.push({
// remove matching page.(tsx|mdx) file and make all URLs absolute
url: `${BASE_URL}/${route.replace(/\/page\.(tsx|mdx)$/, "")}`,
url: `${env.NEXT_PUBLIC_BASE_URL}/${route.replace(/\/page\.(tsx|mdx)$/, "")}`,
});
});