mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-04-26 01:45:25 -04:00
validate environment variables at build time
This commit is contained in:
parent
84702aeab1
commit
eb92e54fd6
@ -23,14 +23,16 @@ NEXT_PUBLIC_UMAMI_URL=
|
|||||||
NEXT_PUBLIC_GISCUS_REPO_ID=
|
NEXT_PUBLIC_GISCUS_REPO_ID=
|
||||||
NEXT_PUBLIC_GISCUS_CATEGORY_ID=
|
NEXT_PUBLIC_GISCUS_CATEGORY_ID=
|
||||||
|
|
||||||
# required for production. sends contact form submissions via a server action (see app/contact/actions.ts).
|
# required for production. sends contact form submissions via a server action (see app/contact/actions.ts). may be set
|
||||||
|
# automatically by Vercel's Resend integration.
|
||||||
# https://resend.com/api-keys
|
# https://resend.com/api-keys
|
||||||
# currently set automatically by Vercel's Resend integration.
|
|
||||||
# https://vercel.com/integrations/resend
|
# https://vercel.com/integrations/resend
|
||||||
RESEND_API_KEY=
|
RESEND_API_KEY=
|
||||||
|
# required. the destination email for contact form submissions.
|
||||||
|
RESEND_TO_EMAIL=
|
||||||
# optional, but will throw a warning. send submissions from an approved domain (or subdomain) on the resend account.
|
# optional, but will throw a warning. send submissions from an approved domain (or subdomain) on the resend account.
|
||||||
# defaults to onboarding@resend.dev.
|
# defaults to onboarding@resend.dev.
|
||||||
# sender's real email is passed via a Reply-To header, setting this makes zero difference to the user.
|
# sender's real email is passed via a Reply-To header, so setting this makes zero difference to the user.
|
||||||
# https://resend.com/domains
|
# https://resend.com/domains
|
||||||
RESEND_FROM_EMAIL=
|
RESEND_FROM_EMAIL=
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
|
import { env } from "../lib/env";
|
||||||
import Script from "next/script";
|
import Script from "next/script";
|
||||||
|
|
||||||
const Analytics = () => {
|
const Analytics = () => {
|
||||||
if (process.env.NEXT_PUBLIC_VERCEL_ENV !== "production") {
|
if (env.VERCEL_ENV !== "production") {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID) {
|
if (!env.NEXT_PUBLIC_UMAMI_WEBSITE_ID) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,8 +15,8 @@ const Analytics = () => {
|
|||||||
src="/_stream/u/script.js" // see next.config.ts rewrite
|
src="/_stream/u/script.js" // see next.config.ts rewrite
|
||||||
id="umami-js"
|
id="umami-js"
|
||||||
strategy="afterInteractive"
|
strategy="afterInteractive"
|
||||||
data-website-id={process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID}
|
data-website-id={env.NEXT_PUBLIC_UMAMI_WEBSITE_ID}
|
||||||
data-domains={process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL}
|
data-domains={env.VERCEL_PROJECT_PRODUCTION_URL}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
import { unstable_cache as cache } from "next/cache";
|
import { unstable_cache as cache } from "next/cache";
|
||||||
import redis from "../../../lib/helpers/redis";
|
import redis from "../../../lib/redis";
|
||||||
|
|
||||||
// cache response from the db
|
// cache response from the db
|
||||||
const getData = cache(
|
const getData = cache(
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
|
import { env } from "../../lib/env";
|
||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
import * as v from "valibot";
|
import * as v from "valibot";
|
||||||
import { Resend } from "resend";
|
import { Resend } from "resend";
|
||||||
@ -49,10 +50,6 @@ export const send = async (state: ContactState, payload: FormData): Promise<Cont
|
|||||||
// TODO: remove after debugging why automated spam entries are causing 500 errors
|
// TODO: remove after debugging why automated spam entries are causing 500 errors
|
||||||
console.debug("[contact form] received payload:", payload);
|
console.debug("[contact form] received payload:", payload);
|
||||||
|
|
||||||
if (!process.env.RESEND_API_KEY) {
|
|
||||||
throw new Error("[contact form] 'RESEND_API_KEY' is not set.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = v.safeParse(ContactSchema, Object.fromEntries(payload));
|
const data = v.safeParse(ContactSchema, Object.fromEntries(payload));
|
||||||
|
|
||||||
@ -75,7 +72,7 @@ export const send = async (state: ContactState, payload: FormData): Promise<Cont
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
secret: process.env.TURNSTILE_SECRET_KEY || "1x0000000000000000000000000000000AA",
|
secret: env.TURNSTILE_SECRET_KEY || "1x0000000000000000000000000000000AA",
|
||||||
response: data.output["cf-turnstile-response"],
|
response: data.output["cf-turnstile-response"],
|
||||||
remoteip,
|
remoteip,
|
||||||
}),
|
}),
|
||||||
@ -95,17 +92,17 @@ export const send = async (state: ContactState, payload: FormData): Promise<Cont
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!process.env.RESEND_FROM_EMAIL) {
|
if (!env.RESEND_FROM_EMAIL) {
|
||||||
// https://resend.com/docs/api-reference/emails/send-email
|
// https://resend.com/docs/api-reference/emails/send-email
|
||||||
console.warn("[contact form] 'RESEND_FROM_EMAIL' is not set, falling back to onboarding@resend.dev.");
|
console.warn("[contact form] 'RESEND_FROM_EMAIL' is not set, falling back to onboarding@resend.dev.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// send email
|
// send email
|
||||||
const resend = new Resend(process.env.RESEND_API_KEY!);
|
const resend = new Resend(env.RESEND_API_KEY);
|
||||||
await resend.emails.send({
|
await resend.emails.send({
|
||||||
from: `${data.output.name} <${process.env.RESEND_FROM_EMAIL || "onboarding@resend.dev"}>`,
|
from: `${data.output.name} <${env.RESEND_FROM_EMAIL || "onboarding@resend.dev"}>`,
|
||||||
replyTo: `${data.output.name} <${data.output.email}>`,
|
replyTo: `${data.output.name} <${data.output.email}>`,
|
||||||
to: [config.authorEmail],
|
to: [env.RESEND_TO_EMAIL],
|
||||||
subject: `[${config.siteName}] Contact Form Submission`,
|
subject: `[${config.siteName}] Contact Form Submission`,
|
||||||
text: data.output.message,
|
text: data.output.message,
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { env } from "../../lib/env";
|
||||||
import { useActionState, useState } from "react";
|
import { useActionState, useState } from "react";
|
||||||
import TextareaAutosize from "react-textarea-autosize";
|
import TextareaAutosize from "react-textarea-autosize";
|
||||||
import Turnstile from "react-turnstile";
|
import Turnstile from "react-turnstile";
|
||||||
@ -104,7 +105,7 @@ const ContactForm = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={{ margin: "1em 0" }}>
|
<div style={{ margin: "1em 0" }}>
|
||||||
<Turnstile sitekey={process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY || "1x00000000000000000000AA"} fixedSize />
|
<Turnstile sitekey={env.NEXT_PUBLIC_TURNSTILE_SITE_KEY || "1x00000000000000000000AA"} fixedSize />
|
||||||
</div>
|
</div>
|
||||||
{!pending && formState.errors?.["cf-turnstile-response"] && (
|
{!pending && formState.errors?.["cf-turnstile-response"] && (
|
||||||
<span className={styles.errorMessage}>{formState.errors["cf-turnstile-response"][0]}</span>
|
<span className={styles.errorMessage}>{formState.errors["cf-turnstile-response"][0]}</span>
|
||||||
|
@ -7,7 +7,7 @@ import { SkipToContentLink, SkipToContentTarget } from "../components/SkipToCont
|
|||||||
import { setRootCssVariables } from "../lib/helpers/styles";
|
import { setRootCssVariables } from "../lib/helpers/styles";
|
||||||
import * as config from "../lib/config";
|
import * as config from "../lib/config";
|
||||||
import { BASE_URL, MAX_WIDTH } from "../lib/config/constants";
|
import { BASE_URL, MAX_WIDTH } from "../lib/config/constants";
|
||||||
import defaultMetadata from "../lib/config/metadata";
|
import defaultMetadata from "../lib/config/seo";
|
||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
import type { Person, WebSite } from "schema-dts";
|
import type { Person, WebSite } from "schema-dts";
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ const RootLayout = ({ children }: Readonly<{ children: React.ReactNode }>) => {
|
|||||||
height: `${ogImage.height}`,
|
height: `${ogImage.height}`,
|
||||||
},
|
},
|
||||||
sameAs: [
|
sameAs: [
|
||||||
BASE_URL,
|
`${BASE_URL}`,
|
||||||
`https://${config.authorSocial?.mastodon}`,
|
`https://${config.authorSocial?.mastodon}`,
|
||||||
`https://github.com/${config.authorSocial?.github}`,
|
`https://github.com/${config.authorSocial?.github}`,
|
||||||
`https://bsky.app/profile/${config.authorSocial?.bluesky}`,
|
`https://bsky.app/profile/${config.authorSocial?.bluesky}`,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { connection } from "next/server";
|
import { connection } from "next/server";
|
||||||
import CountUp from "../../../components/CountUp";
|
import CountUp from "../../../components/CountUp";
|
||||||
import redis from "../../../lib/helpers/redis";
|
import redis from "../../../lib/redis";
|
||||||
import { siteLocale } from "../../../lib/config";
|
import { siteLocale } from "../../../lib/config";
|
||||||
|
|
||||||
const HitCounter = async ({ slug }: { slug: string }) => {
|
const HitCounter = async ({ slug }: { slug: string }) => {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { env } from "../../../lib/env";
|
||||||
import { Suspense } from "react";
|
import { Suspense } from "react";
|
||||||
import { JsonLd } from "react-schemaorg";
|
import { JsonLd } from "react-schemaorg";
|
||||||
import { CalendarIcon, TagIcon, SquarePenIcon, EyeIcon } from "lucide-react";
|
import { CalendarIcon, TagIcon, SquarePenIcon, EyeIcon } from "lucide-react";
|
||||||
@ -20,7 +21,6 @@ import styles from "./page.module.css";
|
|||||||
export const dynamicParams = false;
|
export const dynamicParams = false;
|
||||||
|
|
||||||
// https://nextjs.org/docs/app/building-your-application/rendering/partial-prerendering#using-partial-prerendering
|
// https://nextjs.org/docs/app/building-your-application/rendering/partial-prerendering#using-partial-prerendering
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
export const experimental_ppr = true;
|
export const experimental_ppr = true;
|
||||||
|
|
||||||
export const generateStaticParams = async () => {
|
export const generateStaticParams = async () => {
|
||||||
@ -122,7 +122,7 @@ const Page = async ({ params }: { params: Promise<{ slug: string }> }) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* only count hits on production site */}
|
{/* only count hits on production site */}
|
||||||
{process.env.NEXT_PUBLIC_VERCEL_ENV !== "development" && process.env.NODE_ENV !== "development" ? (
|
{env.VERCEL_ENV === "production" ? (
|
||||||
<div
|
<div
|
||||||
className={styles.metaItem}
|
className={styles.metaItem}
|
||||||
style={{
|
style={{
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { env } from "../../lib/env";
|
||||||
import { notFound } from "next/navigation";
|
import { notFound } from "next/navigation";
|
||||||
import { graphql } from "@octokit/graphql";
|
import { graphql } from "@octokit/graphql";
|
||||||
import { GitForkIcon, StarIcon } from "lucide-react";
|
import { GitForkIcon, StarIcon } from "lucide-react";
|
||||||
@ -20,7 +21,7 @@ export const metadata = addMetadata({
|
|||||||
|
|
||||||
const getRepos = async () => {
|
const getRepos = async () => {
|
||||||
// don't fail the entire site build if the required API key for this page is missing
|
// don't fail the entire site build if the required API key for this page is missing
|
||||||
if (!process.env.GITHUB_TOKEN) {
|
if (!env.GITHUB_TOKEN) {
|
||||||
console.warn(`ERROR: I can't fetch any GitHub projects without "GITHUB_TOKEN" set! Disabling projects page.`);
|
console.warn(`ERROR: I can't fetch any GitHub projects without "GITHUB_TOKEN" set! Disabling projects page.`);
|
||||||
|
|
||||||
// just return a 404 since this page would be blank anyways
|
// just return a 404 since this page would be blank anyways
|
||||||
@ -64,7 +65,7 @@ const getRepos = async () => {
|
|||||||
limit: 12,
|
limit: 12,
|
||||||
headers: {
|
headers: {
|
||||||
accept: "application/vnd.github.v3+json",
|
accept: "application/vnd.github.v3+json",
|
||||||
authorization: `token ${process.env.GITHUB_TOKEN}`,
|
authorization: `token ${env.GITHUB_TOKEN}`,
|
||||||
},
|
},
|
||||||
request: {
|
request: {
|
||||||
// override fetch() to use next's extension to cache the response
|
// override fetch() to use next's extension to cache the response
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import glob from "fast-glob";
|
import glob from "fast-glob";
|
||||||
import { getFrontMatter } from "../lib/helpers/posts";
|
import { getFrontMatter } from "../lib/helpers/posts";
|
||||||
import { BASE_URL } from "../lib/config/constants";
|
import { BASE_URL, RELEASE_TIMESTAMP } from "../lib/config/constants";
|
||||||
import type { MetadataRoute } from "next";
|
import type { MetadataRoute } from "next";
|
||||||
|
|
||||||
const sitemap = async (): Promise<MetadataRoute.Sitemap> => {
|
const sitemap = async (): Promise<MetadataRoute.Sitemap> => {
|
||||||
@ -9,9 +9,9 @@ const sitemap = async (): Promise<MetadataRoute.Sitemap> => {
|
|||||||
const routes: MetadataRoute.Sitemap = [
|
const routes: MetadataRoute.Sitemap = [
|
||||||
{
|
{
|
||||||
// homepage
|
// homepage
|
||||||
url: BASE_URL,
|
url: `${BASE_URL}`,
|
||||||
priority: 1.0,
|
priority: 1.0,
|
||||||
lastModified: new Date(process.env.RELEASE_DATE || Date.now()), // timestamp frozen when a new build is deployed
|
lastModified: new Date(RELEASE_TIMESTAMP), // timestamp frozen when a new build is deployed
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { env } from "../../lib/env";
|
||||||
import Giscus from "@giscus/react";
|
import Giscus from "@giscus/react";
|
||||||
import * as config from "../../lib/config";
|
import * as config from "../../lib/config";
|
||||||
import type { GiscusProps } from "@giscus/react";
|
import type { GiscusProps } from "@giscus/react";
|
||||||
@ -10,7 +11,7 @@ export type CommentsProps = {
|
|||||||
|
|
||||||
const Comments = ({ title }: CommentsProps) => {
|
const Comments = ({ title }: CommentsProps) => {
|
||||||
// fail silently if giscus isn't configured
|
// fail silently if giscus isn't configured
|
||||||
if (!process.env.NEXT_PUBLIC_GISCUS_REPO_ID || !process.env.NEXT_PUBLIC_GISCUS_CATEGORY_ID) {
|
if (!env.NEXT_PUBLIC_GISCUS_REPO_ID || !env.NEXT_PUBLIC_GISCUS_CATEGORY_ID) {
|
||||||
console.warn(
|
console.warn(
|
||||||
"[giscus] not configured, ensure 'NEXT_PUBLIC_GISCUS_REPO_ID' and 'NEXT_PUBLIC_GISCUS_CATEGORY_ID' environment variables are set."
|
"[giscus] not configured, ensure 'NEXT_PUBLIC_GISCUS_REPO_ID' and 'NEXT_PUBLIC_GISCUS_CATEGORY_ID' environment variables are set."
|
||||||
);
|
);
|
||||||
@ -21,10 +22,10 @@ const Comments = ({ title }: CommentsProps) => {
|
|||||||
return (
|
return (
|
||||||
<Giscus
|
<Giscus
|
||||||
repo={config.githubRepo as GiscusProps["repo"]}
|
repo={config.githubRepo as GiscusProps["repo"]}
|
||||||
repoId={process.env.NEXT_PUBLIC_GISCUS_REPO_ID}
|
repoId={env.NEXT_PUBLIC_GISCUS_REPO_ID}
|
||||||
term={title}
|
term={title}
|
||||||
category="Comments"
|
category="Comments"
|
||||||
categoryId={process.env.NEXT_PUBLIC_GISCUS_CATEGORY_ID}
|
categoryId={env.NEXT_PUBLIC_GISCUS_CATEGORY_ID}
|
||||||
mapping="specific"
|
mapping="specific"
|
||||||
reactionsEnabled="1"
|
reactionsEnabled="1"
|
||||||
emitMetadata="0"
|
emitMetadata="0"
|
||||||
|
@ -2,6 +2,7 @@ import clsx from "clsx";
|
|||||||
import { HeartIcon } from "lucide-react";
|
import { HeartIcon } from "lucide-react";
|
||||||
import Link from "../Link";
|
import Link from "../Link";
|
||||||
import * as config from "../../lib/config";
|
import * as config from "../../lib/config";
|
||||||
|
import { RELEASE_TIMESTAMP } from "../../lib/config/constants";
|
||||||
import type { ComponentPropsWithoutRef } from "react";
|
import type { ComponentPropsWithoutRef } from "react";
|
||||||
|
|
||||||
import styles from "./Footer.module.css";
|
import styles from "./Footer.module.css";
|
||||||
@ -21,7 +22,7 @@ const Footer = ({ className, ...rest }: FooterProps) => {
|
|||||||
<Link href="/previously" title="Previously on..." plain className={styles.link}>
|
<Link href="/previously" title="Previously on..." plain className={styles.link}>
|
||||||
{config.copyrightYearStart}
|
{config.copyrightYearStart}
|
||||||
</Link>{" "}
|
</Link>{" "}
|
||||||
– {new Date(process.env.RELEASE_DATE || Date.now()).getUTCFullYear()}.
|
– {new Date(RELEASE_TIMESTAMP).getUTCFullYear()}.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
@ -65,8 +65,3 @@ export const ThemeScript = () => (
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
// debugging help pls
|
|
||||||
if (process.env.NODE_ENV !== "production") {
|
|
||||||
ThemeContext.displayName = "ThemeContext";
|
|
||||||
}
|
|
||||||
|
@ -26,7 +26,7 @@ export default [
|
|||||||
camelcase: [
|
camelcase: [
|
||||||
"error",
|
"error",
|
||||||
{
|
{
|
||||||
allow: ["^unstable_"],
|
allow: ["^experimental_", "^unstable_"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"prettier/prettier": [
|
"prettier/prettier": [
|
||||||
|
@ -8,10 +8,6 @@ export const AVATAR_PATH = "app/avatar.jpg";
|
|||||||
// maximum width of content wrapper (e.g. for images) in pixels
|
// maximum width of content wrapper (e.g. for images) in pixels
|
||||||
export const MAX_WIDTH = 865;
|
export const MAX_WIDTH = 865;
|
||||||
|
|
||||||
// same logic as metadataBase: https://nextjs.org/docs/app/api-reference/functions/generate-metadata#default-value
|
// defined in next.config.ts
|
||||||
export const BASE_URL =
|
export const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL!;
|
||||||
process.env.NEXT_PUBLIC_VERCEL_ENV === "production" && process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL
|
export const RELEASE_TIMESTAMP = process.env.NEXT_PUBLIC_RELEASE_TIMESTAMP!;
|
||||||
? `https://${process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL}`
|
|
||||||
: process.env.NEXT_PUBLIC_VERCEL_ENV === "preview" && process.env.NEXT_PUBLIC_VERCEL_URL
|
|
||||||
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
|
|
||||||
: `http://localhost:${process.env.PORT || 3000}`;
|
|
||||||
|
@ -2,7 +2,7 @@ import * as config from ".";
|
|||||||
import { BASE_URL } from "./constants";
|
import { BASE_URL } from "./constants";
|
||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
const metadata: Metadata = {
|
const defaultMetadata: Metadata = {
|
||||||
metadataBase: new URL(BASE_URL),
|
metadataBase: new URL(BASE_URL),
|
||||||
title: {
|
title: {
|
||||||
template: `%s – ${config.siteName}`,
|
template: `%s – ${config.siteName}`,
|
||||||
@ -44,4 +44,4 @@ const metadata: Metadata = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default metadata;
|
export default defaultMetadata;
|
34
lib/env.ts
Normal file
34
lib/env.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { createEnv } from "@t3-oss/env-nextjs";
|
||||||
|
import { vercel } from "@t3-oss/env-nextjs/presets-valibot";
|
||||||
|
import * as v from "valibot";
|
||||||
|
|
||||||
|
export const env = createEnv({
|
||||||
|
extends: [vercel()],
|
||||||
|
server: {
|
||||||
|
GITHUB_TOKEN: v.optional(v.pipe(v.string(), v.startsWith("ghp_"))),
|
||||||
|
KV_REST_API_TOKEN: v.string(),
|
||||||
|
KV_REST_API_URL: v.pipe(v.string(), v.url(), v.startsWith("https://"), v.endsWith(".upstash.io")),
|
||||||
|
RESEND_API_KEY: v.pipe(v.string(), v.startsWith("re_")),
|
||||||
|
RESEND_FROM_EMAIL: v.optional(v.pipe(v.string(), v.email())),
|
||||||
|
RESEND_TO_EMAIL: v.pipe(v.string(), v.email()),
|
||||||
|
TURNSTILE_SECRET_KEY: v.optional(v.string()),
|
||||||
|
},
|
||||||
|
client: {
|
||||||
|
NEXT_PUBLIC_GISCUS_CATEGORY_ID: v.optional(v.string()),
|
||||||
|
NEXT_PUBLIC_GISCUS_REPO_ID: v.optional(v.string()),
|
||||||
|
NEXT_PUBLIC_ONION_DOMAIN: v.optional(v.pipe(v.string(), v.endsWith(".onion"))),
|
||||||
|
NEXT_PUBLIC_TURNSTILE_SITE_KEY: v.optional(v.string()),
|
||||||
|
NEXT_PUBLIC_UMAMI_URL: v.optional(v.pipe(v.string(), v.url())),
|
||||||
|
NEXT_PUBLIC_UMAMI_WEBSITE_ID: v.optional(v.string()),
|
||||||
|
},
|
||||||
|
experimental__runtimeEnv: {
|
||||||
|
NEXT_PUBLIC_GISCUS_CATEGORY_ID: process.env.NEXT_PUBLIC_GISCUS_CATEGORY_ID,
|
||||||
|
NEXT_PUBLIC_GISCUS_REPO_ID: process.env.NEXT_PUBLIC_GISCUS_REPO_ID,
|
||||||
|
NEXT_PUBLIC_ONION_DOMAIN: process.env.NEXT_PUBLIC_ONION_DOMAIN,
|
||||||
|
NEXT_PUBLIC_TURNSTILE_SITE_KEY: process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY,
|
||||||
|
NEXT_PUBLIC_UMAMI_URL: process.env.NEXT_PUBLIC_UMAMI_URL,
|
||||||
|
NEXT_PUBLIC_UMAMI_WEBSITE_ID: process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID,
|
||||||
|
},
|
||||||
|
emptyStringAsUndefined: true,
|
||||||
|
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
|
||||||
|
});
|
@ -1,7 +1,7 @@
|
|||||||
import { Feed } from "feed";
|
import { Feed } from "feed";
|
||||||
import { getFrontMatter, getContent } from "./posts";
|
import { getFrontMatter, getContent } from "./posts";
|
||||||
import * as config from "../config";
|
import * as config from "../config";
|
||||||
import { BASE_URL } from "../config/constants";
|
import { BASE_URL, RELEASE_TIMESTAMP } from "../config/constants";
|
||||||
import type { Item as FeedItem } from "feed";
|
import type { Item as FeedItem } from "feed";
|
||||||
|
|
||||||
import ogImage from "../../app/opengraph-image.jpg";
|
import ogImage from "../../app/opengraph-image.jpg";
|
||||||
@ -12,12 +12,12 @@ import ogImage from "../../app/opengraph-image.jpg";
|
|||||||
*/
|
*/
|
||||||
export const buildFeed = async (): Promise<Feed> => {
|
export const buildFeed = async (): Promise<Feed> => {
|
||||||
const feed = new Feed({
|
const feed = new Feed({
|
||||||
id: BASE_URL,
|
id: `${BASE_URL}`,
|
||||||
link: BASE_URL,
|
link: `${BASE_URL}`,
|
||||||
title: config.siteName,
|
title: config.siteName,
|
||||||
description: config.longDescription,
|
description: config.longDescription,
|
||||||
copyright: config.licenseUrl,
|
copyright: config.licenseUrl,
|
||||||
updated: new Date(process.env.RELEASE_DATE || Date.now()),
|
updated: new Date(RELEASE_TIMESTAMP),
|
||||||
image: `${BASE_URL}${ogImage.src}`,
|
image: `${BASE_URL}${ogImage.src}`,
|
||||||
feedLinks: {
|
feedLinks: {
|
||||||
rss: `${BASE_URL}/feed.xml`,
|
rss: `${BASE_URL}/feed.xml`,
|
||||||
@ -41,7 +41,7 @@ export const buildFeed = async (): Promise<Feed> => {
|
|||||||
author: [
|
author: [
|
||||||
{
|
{
|
||||||
name: config.authorName,
|
name: config.authorName,
|
||||||
link: BASE_URL,
|
link: `${BASE_URL}`,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
date: new Date(post.date),
|
date: new Date(post.date),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import defaultMetadata from "../config/metadata";
|
import defaultMetadata from "../config/seo";
|
||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,13 +5,27 @@ import { visit } from "unist-util-visit";
|
|||||||
import * as mdxPlugins from "./lib/helpers/remark-rehype-plugins";
|
import * as mdxPlugins from "./lib/helpers/remark-rehype-plugins";
|
||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
|
// check environment variables at build time
|
||||||
|
// https://env.t3.gg/docs/nextjs#validate-schema-on-build-(recommended)
|
||||||
|
import "./lib/env";
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
productionBrowserSourceMaps: true,
|
productionBrowserSourceMaps: true,
|
||||||
env: {
|
env: {
|
||||||
|
// same logic as metadataBase: https://nextjs.org/docs/app/api-reference/functions/generate-metadata#default-value
|
||||||
|
NEXT_PUBLIC_BASE_URL:
|
||||||
|
process.env.VERCEL_ENV === "production" && process.env.VERCEL_PROJECT_PRODUCTION_URL
|
||||||
|
? `https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}`
|
||||||
|
: process.env.VERCEL_ENV === "preview" && process.env.VERCEL_BRANCH_URL
|
||||||
|
? `https://${process.env.VERCEL_BRANCH_URL}`
|
||||||
|
: process.env.VERCEL_URL
|
||||||
|
? `https://${process.env.VERCEL_URL}`
|
||||||
|
: `http://localhost:${process.env.PORT || 3000}`,
|
||||||
|
|
||||||
// freeze timestamp at build time for when server-side pages need a "last updated" date. calling Date.now() from
|
// freeze timestamp at build time for when server-side pages need a "last updated" date. calling Date.now() from
|
||||||
// pages using getServerSideProps will return the current(ish) time instead, which is usually not what we want.
|
// pages using getServerSideProps will return the current(ish) time instead, which is usually not what we want.
|
||||||
RELEASE_DATE: new Date().toISOString(),
|
NEXT_PUBLIC_RELEASE_TIMESTAMP: new Date().toISOString(),
|
||||||
},
|
},
|
||||||
pageExtensions: ["js", "jsx", "ts", "tsx", "md", "mdx"],
|
pageExtensions: ["js", "jsx", "ts", "tsx", "md", "mdx"],
|
||||||
outputFileTracingIncludes: {
|
outputFileTracingIncludes: {
|
||||||
@ -25,6 +39,7 @@ const nextConfig: NextConfig = {
|
|||||||
outputFileTracingExcludes: {
|
outputFileTracingExcludes: {
|
||||||
"*": ["./public/**/*", "**/*.mp4", "**/*.webm", "**/*.vtt"],
|
"*": ["./public/**/*", "**/*.mp4", "**/*.webm", "**/*.vtt"],
|
||||||
},
|
},
|
||||||
|
transpilePackages: ["@t3-oss/env-nextjs", "@t3-oss/env-core"],
|
||||||
webpack: (config) => {
|
webpack: (config) => {
|
||||||
config.module.rules.push({
|
config.module.rules.push({
|
||||||
test: /\.(mp4|webm|vtt)$/i,
|
test: /\.(mp4|webm|vtt)$/i,
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
"@next/mdx": "15.3.0-canary.45",
|
"@next/mdx": "15.3.0-canary.45",
|
||||||
"@octokit/graphql": "^8.2.1",
|
"@octokit/graphql": "^8.2.1",
|
||||||
"@octokit/graphql-schema": "^15.26.0",
|
"@octokit/graphql-schema": "^15.26.0",
|
||||||
|
"@t3-oss/env-nextjs": "^0.12.0",
|
||||||
"@upstash/redis": "^1.34.7",
|
"@upstash/redis": "^1.34.7",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"copy-to-clipboard": "^3.3.3",
|
"copy-to-clipboard": "^3.3.3",
|
||||||
@ -74,7 +75,7 @@
|
|||||||
"@types/node": "^22.14.0",
|
"@types/node": "^22.14.0",
|
||||||
"@types/prop-types": "^15.7.14",
|
"@types/prop-types": "^15.7.14",
|
||||||
"@types/react": "^19.1.0",
|
"@types/react": "^19.1.0",
|
||||||
"@types/react-dom": "^19.1.1",
|
"@types/react-dom": "^19.1.2",
|
||||||
"@types/react-is": "^19.0.0",
|
"@types/react-is": "^19.0.0",
|
||||||
"babel-plugin-react-compiler": "19.0.0-beta-e993439-20250405",
|
"babel-plugin-react-compiler": "19.0.0-beta-e993439-20250405",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
|
55
pnpm-lock.yaml
generated
55
pnpm-lock.yaml
generated
@ -38,6 +38,9 @@ importers:
|
|||||||
'@octokit/graphql-schema':
|
'@octokit/graphql-schema':
|
||||||
specifier: ^15.26.0
|
specifier: ^15.26.0
|
||||||
version: 15.26.0
|
version: 15.26.0
|
||||||
|
'@t3-oss/env-nextjs':
|
||||||
|
specifier: ^0.12.0
|
||||||
|
version: 0.12.0(typescript@5.8.3)(valibot@1.0.0(typescript@5.8.3))(zod@3.24.2)
|
||||||
'@upstash/redis':
|
'@upstash/redis':
|
||||||
specifier: ^1.34.7
|
specifier: ^1.34.7
|
||||||
version: 1.34.7
|
version: 1.34.7
|
||||||
@ -175,8 +178,8 @@ importers:
|
|||||||
specifier: ^19.1.0
|
specifier: ^19.1.0
|
||||||
version: 19.1.0
|
version: 19.1.0
|
||||||
'@types/react-dom':
|
'@types/react-dom':
|
||||||
specifier: ^19.1.1
|
specifier: ^19.1.2
|
||||||
version: 19.1.1(@types/react@19.1.0)
|
version: 19.1.2(@types/react@19.1.0)
|
||||||
'@types/react-is':
|
'@types/react-is':
|
||||||
specifier: ^19.0.0
|
specifier: ^19.0.0
|
||||||
version: 19.0.0
|
version: 19.0.0
|
||||||
@ -832,6 +835,34 @@ packages:
|
|||||||
'@swc/helpers@0.5.15':
|
'@swc/helpers@0.5.15':
|
||||||
resolution: {integrity: sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==}
|
resolution: {integrity: sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==}
|
||||||
|
|
||||||
|
'@t3-oss/env-core@0.12.0':
|
||||||
|
resolution: {integrity: sha512-lOPj8d9nJJTt81mMuN9GMk8x5veOt7q9m11OSnCBJhwp1QrL/qR+M8Y467ULBSm9SunosryWNbmQQbgoiMgcdw==}
|
||||||
|
peerDependencies:
|
||||||
|
typescript: '>=5.0.0'
|
||||||
|
valibot: ^1.0.0-beta.7 || ^1.0.0
|
||||||
|
zod: ^3.24.0
|
||||||
|
peerDependenciesMeta:
|
||||||
|
typescript:
|
||||||
|
optional: true
|
||||||
|
valibot:
|
||||||
|
optional: true
|
||||||
|
zod:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@t3-oss/env-nextjs@0.12.0':
|
||||||
|
resolution: {integrity: sha512-rFnvYk1049RnNVUPvY8iQ55AuQh1Rr+qZzQBh3t++RttCGK4COpXGNxS4+45afuQq02lu+QAOy/5955aU8hRKw==}
|
||||||
|
peerDependencies:
|
||||||
|
typescript: '>=5.0.0'
|
||||||
|
valibot: ^1.0.0-beta.7 || ^1.0.0
|
||||||
|
zod: ^3.24.0
|
||||||
|
peerDependenciesMeta:
|
||||||
|
typescript:
|
||||||
|
optional: true
|
||||||
|
valibot:
|
||||||
|
optional: true
|
||||||
|
zod:
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@tybys/wasm-util@0.9.0':
|
'@tybys/wasm-util@0.9.0':
|
||||||
resolution: {integrity: sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw==}
|
resolution: {integrity: sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw==}
|
||||||
|
|
||||||
@ -877,8 +908,8 @@ packages:
|
|||||||
'@types/prop-types@15.7.14':
|
'@types/prop-types@15.7.14':
|
||||||
resolution: {integrity: sha512-gNMvNH49DJ7OJYv+KAKn0Xp45p8PLl6zo2YnvDIbTd4J6MER2BmWN49TG7n9LvkyihINxeKW8+3bfS2yDC9dzQ==}
|
resolution: {integrity: sha512-gNMvNH49DJ7OJYv+KAKn0Xp45p8PLl6zo2YnvDIbTd4J6MER2BmWN49TG7n9LvkyihINxeKW8+3bfS2yDC9dzQ==}
|
||||||
|
|
||||||
'@types/react-dom@19.1.1':
|
'@types/react-dom@19.1.2':
|
||||||
resolution: {integrity: sha512-jFf/woGTVTjUJsl2O7hcopJ1r0upqoq/vIOoCj0yLh3RIXxWcljlpuZ+vEBRXsymD1jhfeJrlyTy/S1UW+4y1w==}
|
resolution: {integrity: sha512-XGJkWF41Qq305SKWEILa1O8vzhb3aOo3ogBlSmiqNko/WmRb6QIaweuZCXjKygVDXpzXb5wyxKTSOsmkuqj+Qw==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@types/react': ^19.0.0
|
'@types/react': ^19.0.0
|
||||||
|
|
||||||
@ -4350,6 +4381,20 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
tslib: 2.8.1
|
tslib: 2.8.1
|
||||||
|
|
||||||
|
'@t3-oss/env-core@0.12.0(typescript@5.8.3)(valibot@1.0.0(typescript@5.8.3))(zod@3.24.2)':
|
||||||
|
optionalDependencies:
|
||||||
|
typescript: 5.8.3
|
||||||
|
valibot: 1.0.0(typescript@5.8.3)
|
||||||
|
zod: 3.24.2
|
||||||
|
|
||||||
|
'@t3-oss/env-nextjs@0.12.0(typescript@5.8.3)(valibot@1.0.0(typescript@5.8.3))(zod@3.24.2)':
|
||||||
|
dependencies:
|
||||||
|
'@t3-oss/env-core': 0.12.0(typescript@5.8.3)(valibot@1.0.0(typescript@5.8.3))(zod@3.24.2)
|
||||||
|
optionalDependencies:
|
||||||
|
typescript: 5.8.3
|
||||||
|
valibot: 1.0.0(typescript@5.8.3)
|
||||||
|
zod: 3.24.2
|
||||||
|
|
||||||
'@tybys/wasm-util@0.9.0':
|
'@tybys/wasm-util@0.9.0':
|
||||||
dependencies:
|
dependencies:
|
||||||
tslib: 2.8.1
|
tslib: 2.8.1
|
||||||
@ -4397,7 +4442,7 @@ snapshots:
|
|||||||
|
|
||||||
'@types/prop-types@15.7.14': {}
|
'@types/prop-types@15.7.14': {}
|
||||||
|
|
||||||
'@types/react-dom@19.1.1(@types/react@19.1.0)':
|
'@types/react-dom@19.1.2(@types/react@19.1.0)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/react': 19.1.0
|
'@types/react': 19.1.0
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user