mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2026-06-05 19:15:30 -04:00
refactor: update font imports and variables
- Replaced GeistSans and GeistMono with Inter and JetBrainsMono in globals.css and layout.tsx. - Updated font variable names to reflect the new font choices in fonts.ts.
This commit is contained in:
+6
-6
@@ -2,22 +2,22 @@
|
||||
// https://nextjs.org/docs/pages/building-your-application/optimizing/fonts#reusing-fonts
|
||||
|
||||
import {
|
||||
Geist as GeistSansLoader,
|
||||
Geist_Mono as GeistMonoLoader,
|
||||
Inter as InterLoader,
|
||||
JetBrains_Mono as JetBrainsMonoLoader,
|
||||
Comic_Neue as ComicNeueLoader,
|
||||
} from "next/font/google";
|
||||
|
||||
export const GeistSans = GeistSansLoader({
|
||||
export const Inter = InterLoader({
|
||||
subsets: ["latin"],
|
||||
display: "swap",
|
||||
variable: "--font-geist-sans",
|
||||
variable: "--font-inter",
|
||||
preload: true,
|
||||
});
|
||||
|
||||
export const GeistMono = GeistMonoLoader({
|
||||
export const JetBrainsMono = JetBrainsMonoLoader({
|
||||
subsets: ["latin"],
|
||||
display: "swap",
|
||||
variable: "--font-geist-mono",
|
||||
variable: "--font-jetbrains-mono",
|
||||
preload: true,
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { cacheLife } from "next/cache";
|
||||
|
||||
// Load a Google Font from the Google Fonts API
|
||||
// Adapted from https://github.com/brianlovin/briOS/blob/f72dc33a11194de45c80337b22be4560da62ad7e/src/lib/og-utils.tsx#L32
|
||||
export async function loadGoogleFont(font: string, weight: number): Promise<ArrayBuffer> {
|
||||
"use cache";
|
||||
|
||||
const url = `https://fonts.googleapis.com/css2?family=${font}:wght@${weight}`;
|
||||
|
||||
const cssResponse = await fetch(url, {
|
||||
next: {
|
||||
revalidate: 31_536_000, // 1 year
|
||||
},
|
||||
});
|
||||
const css = await cssResponse.text();
|
||||
const resource = css.match(/src: url\((.+)\) format\('(opentype|truetype)'\)/);
|
||||
|
||||
if (resource) {
|
||||
const fontResponse = await fetch(resource[1], {
|
||||
next: {
|
||||
revalidate: 31_536_000, // 1 year
|
||||
},
|
||||
});
|
||||
if (fontResponse.status === 200) {
|
||||
cacheLife("max"); // cache indefinitely if successful
|
||||
return fontResponse.arrayBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`Failed to load font: ${font} ${weight}`);
|
||||
}
|
||||
Reference in New Issue
Block a user