Astro.js 作為一個強調 BLOG 的 framework , 那肯定少不了字型的設定啦 ~
下面我們來說明在 Astro.js 如何設定字型吧~
This example will demonstrate adding a custom font using the font file DistantGalaxy.woff.
Add your font file to public/fonts/.
Add the following @font-face statement to your CSS. This could be in a global .css file you import, a block, or a block in a specific layout or component where you want to use this font.
/* Register your custom font family and tell the browser where to find it. */
@font-face {
font-family: 'DistantGalaxy';
src: url('/fonts/DistantGalaxy.woff') format('woff');
font-weight: normal;
font-style: normal;
font-display: swap;
}
---
---
<h1>In a galaxy far, far away...</h1>
<p>Custom fonts make my headings much cooler!</p>
<style>
h1 {
font-family: 'DistantGalaxy', sans-serif;
}
</style>
npm install @fontsource/twinkle-star
+const defaultTheme = require("tailwindcss/defaultTheme");
module.exports = {
// ...
theme: {
extend: {
+ fontFamily: {
+ sans: ["InterVariable", "Inter", ...defaultTheme.fontFamily.sans],
+ },
},
},
// ...
};