mirror of
https://github.com/jimeh/commonflow.org.git
synced 2026-02-19 05:46:40 +00:00
feat: migrate to Astro's experimental font API
Replace @fontsource-variable NPM packages with Astro's built-in experimental font API using the Fontsource provider. Fonts are now fetched at build time, cached locally, and served with the site. This provides automatic @font-face generation, preload link injection, and metric-adjusted fallback fonts (size-adjust, ascent-override, etc.) to reduce CLS during font loading. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { defineConfig } from "astro/config";
|
||||
import { defineConfig, fontProviders } from "astro/config";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import sitemap from "@astrojs/sitemap";
|
||||
import icon from "astro-icon";
|
||||
@@ -10,4 +10,29 @@ export default defineConfig({
|
||||
vite: {
|
||||
plugins: [tailwindcss()],
|
||||
},
|
||||
experimental: {
|
||||
fonts: [
|
||||
{
|
||||
provider: fontProviders.fontsource(),
|
||||
name: "Bricolage Grotesque",
|
||||
cssVariable: "--font-bricolage",
|
||||
weights: ["200 800"],
|
||||
fallbacks: ["system-ui", "sans-serif"],
|
||||
},
|
||||
{
|
||||
provider: fontProviders.fontsource(),
|
||||
name: "DM Sans",
|
||||
cssVariable: "--font-dm-sans",
|
||||
weights: ["100 1000"],
|
||||
fallbacks: ["system-ui", "sans-serif"],
|
||||
},
|
||||
{
|
||||
provider: fontProviders.fontsource(),
|
||||
name: "JetBrains Mono",
|
||||
cssVariable: "--font-jetbrains",
|
||||
weights: ["100 800"],
|
||||
fallbacks: ["SF Mono", "Consolas", "monospace"],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user