### Install astro-font Source: https://github.com/rishi-raj-jain/astro-font/blob/master/README.md Installs the astro-font package using npm, yarn, or pnpm. ```bash npm install astro-font ## or yarn yarn add astro-font ## or pnpm pnpm add astro-font ``` -------------------------------- ### Install astro-font Source: https://github.com/rishi-raj-jain/astro-font/blob/master/packages/astro-font/README.md Installs the astro-font package using npm, yarn, or pnpm. ```bash npm install astro-font ## or yarn yarn add astro-font ## or pnpm pnpm add astro-font ``` -------------------------------- ### Configure CSS Variable for Astro Font Source: https://github.com/rishi-raj-jain/astro-font/blob/master/README.md Demonstrates how to use the `cssVariable` attribute to specify a CSS variable for a font. This allows you to control the font-family using CSS variables, with an example of setting it to 'astro-font'. ```astro --- import { join } from "node:path" --- ``` -------------------------------- ### Configure CSS Variable for Astro Font Source: https://github.com/rishi-raj-jain/astro-font/blob/master/packages/astro-font/README.md Demonstrates how to use the `cssVariable` attribute to specify a CSS variable for a font. This allows you to control the font-family using CSS variables, with an example of setting it to 'astro-font'. ```astro --- import { join } from "node:path" --- ``` -------------------------------- ### Configure Fallback Font Name for Astro Font Source: https://github.com/rishi-raj-jain/astro-font/blob/master/README.md Illustrates how to use the `fallbackName` attribute to set a custom fallback font family name in CSS. This example shows setting custom fallback names for 'Afacad' and 'Inter' fonts. ```astro --- import { join } from "node:path" --- ``` -------------------------------- ### Configure Fallback Font Name for Astro Font Source: https://github.com/rishi-raj-jain/astro-font/blob/master/packages/astro-font/README.md Illustrates how to use the `fallbackName` attribute to set a custom fallback font family name in CSS. This example shows setting custom fallback names for 'Afacad' and 'Inter' fonts. ```astro --- import { join } from "node:path" --- ``` -------------------------------- ### Astro Font Configuration with Fetch Source: https://github.com/rishi-raj-jain/astro-font/blob/master/packages/astro-font/README.md Demonstrates how to configure Astro Font to fetch fonts from Google Fonts. The `fetch: true` option instructs the library to download and manage the font files locally. This configuration includes settings for preloading, font display strategy, fallback fonts, and cache directory. ```astro ``` -------------------------------- ### Astro Font Configuration with Fetch Source: https://github.com/rishi-raj-jain/astro-font/blob/master/README.md Demonstrates how to configure Astro Font to fetch fonts from Google Fonts. The `fetch: true` option instructs the library to download and manage the font files locally. This configuration includes settings for preloading, font display strategy, fallback fonts, and cache directory. ```astro ``` -------------------------------- ### Astro Font Integration Source: https://github.com/rishi-raj-jain/astro-font/blob/master/README.md Shows how to add the Astro Font integration to an Astro project's configuration file. This integration ensures that fetched font files are correctly bundled with the Astro build, making them available for self-hosting. ```javascript // File: astro.config.mjs import { astroFont } from 'astro-font/integration' // ... integrations: [ astroFont() ] // ... ``` -------------------------------- ### Astro Font Integration Source: https://github.com/rishi-raj-jain/astro-font/blob/master/packages/astro-font/README.md Shows how to add the Astro Font integration to an Astro project's configuration file. This integration ensures that fetched font files are correctly bundled with the Astro build, making them available for self-hosting. ```javascript // File: astro.config.mjs import { astroFont } from 'astro-font/integration' // ... integrations: [ astroFont() ] // ... ``` -------------------------------- ### Using Multiple Fonts Source: https://github.com/rishi-raj-jain/astro-font/blob/master/README.md Demonstrates how to import and use multiple fonts within a single AstroFont configuration. This involves extending the `config` array with different font definitions. ```astro --- import { join } from "node:path"; import { AstroFont } from "astro-font"; --- span", fallback: "serif", }, ]} /> ``` -------------------------------- ### Configuring CSS Classes with Selector Source: https://github.com/rishi-raj-jain/astro-font/blob/master/README.md Shows how to use the `selector` attribute within the astro-font configuration to target specific CSS classes or selectors for font application. This allows for more granular control over where font styles are applied. ```astro --- import { join } from "node:path" --- span", }, ]} /> ``` -------------------------------- ### Using Multiple Fonts Source: https://github.com/rishi-raj-jain/astro-font/blob/master/packages/astro-font/README.md Demonstrates how to import and use multiple fonts within a single AstroFont configuration. This involves extending the `config` array with different font definitions. ```astro --- import { join } from "node:path"; import { AstroFont } from "astro-font"; --- span", fallback: "serif", }, ]} /> ``` -------------------------------- ### Configuring CSS Classes with Selector Source: https://github.com/rishi-raj-jain/astro-font/blob/master/packages/astro-font/README.md Shows how to use the `selector` attribute within the astro-font configuration to target specific CSS classes or selectors for font application. This allows for more granular control over where font styles are applied. ```astro --- import { join } from "node:path" --- span", }, ]} /> ``` -------------------------------- ### Opt out of bundling Node.js built-ins for Cloudflare Source: https://github.com/rishi-raj-jain/astro-font/blob/master/README.md Shows how to modify the `astro.config.mjs` file to opt out of bundling Node.js built-ins, which is necessary for using Node.js imports like `node:path` in Cloudflare Workers. This involves adding a `vite.ssr.external` configuration. ```diff // File: astro.config.mjs import { defineConfig } from 'astro/config'; import cloudflare from '@astrojs/cloudflare'; // https://astro.build/config export default defineConfig({ output: 'server', adapter: cloudflare(), + vite: { + ssr: { + external: ["buffer", "path", "fs", "os", "crypto", "async_hooks"].map((i) => `node:${i}`), + }, + // make sure to use node:fs, node:path, or node:os if you are using it in your project instead of fs, path or os + }, }); ``` -------------------------------- ### Optimize Local Fonts Source: https://github.com/rishi-raj-jain/astro-font/blob/master/README.md Configures astro-font to optimize local fonts. It uses Node.js `path.join` to specify the font file paths within the project's public directory. ```astro --- import { join } from "node:path"; import { AstroFont } from "astro-font"; --- ``` -------------------------------- ### Astro Font Configuration for Cloudflare Workers (SSR) Source: https://github.com/rishi-raj-jain/astro-font/blob/master/README.md Provides a code snippet for configuring Astro Font with local fonts when using Astro's server-side rendering with Cloudflare. It dynamically sets the font prefix based on the environment to correctly reference local font files. ```astro --- import { join } from "node:path"; import { AstroFont } from "astro-font"; const fontPrefix = import.meta.env.PROD ? Astro.site.toString() : join(process.cwd(), "public"); --- ``` -------------------------------- ### Optimize Local Fonts Source: https://github.com/rishi-raj-jain/astro-font/blob/master/packages/astro-font/README.md Configures astro-font to optimize local fonts. It uses Node.js `path.join` to specify the font file paths within the project's public directory. ```astro --- import { join } from "node:path"; import { AstroFont } from "astro-font"; --- ``` -------------------------------- ### Opt out of bundling Node.js built-ins for Cloudflare Source: https://github.com/rishi-raj-jain/astro-font/blob/master/packages/astro-font/README.md Shows how to modify the `astro.config.mjs` file to opt out of bundling Node.js built-ins, which is necessary for using Node.js imports like `node:path` in Cloudflare Workers. This involves adding a `vite.ssr.external` configuration. ```diff // File: astro.config.mjs import { defineConfig } from 'astro/config'; import cloudflare from '@astrojs/cloudflare'; // https://astro.build/config export default defineConfig({ output: 'server', adapter: cloudflare(), + vite: { + ssr: { + external: ["buffer", "path", "fs", "os", "crypto", "async_hooks"].map((i) => `node:${i}`), + }, + // make sure to use node:fs, node:path, or node:os if you are using it in your project instead of fs, path or os + }, }); ``` -------------------------------- ### Astro Font Configuration for Cloudflare Workers (SSR) Source: https://github.com/rishi-raj-jain/astro-font/blob/master/packages/astro-font/README.md Provides a code snippet for configuring Astro Font with local fonts when using Astro's server-side rendering with Cloudflare. It dynamically sets the font prefix based on the environment to correctly reference local font files. ```astro --- import { join } from "node:path"; import { AstroFont } from "astro-font"; const fontPrefix = import.meta.env.PROD ? Astro.site.toString() : join(process.cwd(), "public"); --- ``` -------------------------------- ### Optimize Picked Google Fonts Source: https://github.com/rishi-raj-jain/astro-font/blob/master/packages/astro-font/README.md Configures astro-font to optimize specific fonts picked from a Google Fonts URL. It requires providing the direct path to the font file. ```astro --- import { AstroFont } from "astro-font"; --- ``` -------------------------------- ### Optimize Picked Google Fonts Source: https://github.com/rishi-raj-jain/astro-font/blob/master/README.md Configures astro-font to optimize specific fonts picked from a Google Fonts URL. It requires providing the direct path to the font file. ```astro --- import { AstroFont } from "astro-font"; --- ``` -------------------------------- ### Optimize Google Fonts Directly Source: https://github.com/rishi-raj-jain/astro-font/blob/master/README.md Configures astro-font to optimize Google Fonts by providing the Google Fonts URL directly. This snippet shows how to include the AstroFont component in the head of an Astro layout. ```astro --- import { AstroFont } from "astro-font"; --- ``` -------------------------------- ### Optimize Google Fonts Directly Source: https://github.com/rishi-raj-jain/astro-font/blob/master/packages/astro-font/README.md Configures astro-font to optimize Google Fonts by providing the Google Fonts URL directly. This snippet shows how to include the AstroFont component in the head of an Astro layout. ```astro --- import { AstroFont } from "astro-font"; --- ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.