diff --git a/package.json b/package.json index db3eaba..784586d 100755 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@astrojs/tailwind": "^5.1.0", "astro": "^4.0.9", "astro-auto-import": "^0.4.2", + "astro-font": "^0.0.77", "date-fns": "^3.0.6", "disqus-react": "^1.1.5", "github-slugger": "^2.0.0", @@ -52,8 +53,8 @@ "prettier-plugin-astro": "^0.12.3", "prettier-plugin-tailwindcss": "^0.5.10", "sass": "^1.69.7", - "tailwindcss": "^3.4.0", "tailwind-bootstrap-grid": "^5.1.0", + "tailwindcss": "^3.4.0", "typescript": "5.3.3" } } diff --git a/src/layouts/Base.astro b/src/layouts/Base.astro index cec2c8f..87e97e5 100755 --- a/src/layouts/Base.astro +++ b/src/layouts/Base.astro @@ -1,4 +1,5 @@ --- +import { AstroFont } from "astro-font"; import TwSizeIndicator from "@/components/TwSizeIndicator.astro"; import config from "@/config/config.json"; import theme from "@/config/theme.json"; @@ -13,6 +14,18 @@ import SearchModal from "./helpers/SearchModal"; const pf = theme.fonts.font_family.primary; const sf = theme.fonts.font_family.secondary; +let fontPrimary, fontSecondary; +if (theme.fonts.font_family.primary) { + fontPrimary = theme.fonts.font_family.primary + .replace(/\+/g, " ") + .replace(/:[ital,]*[ital@]*[wght@]*[0-9,;]+/gi, ""); +} +if (theme.fonts.font_family.secondary) { + fontSecondary = theme.fonts.font_family.secondary + .replace(/\+/g, " ") + .replace(/:[ital,]*[ital@]*[wght@]*[0-9,;]+/gi, ""); +} + // types for frontmatters export interface Props { title?: string; @@ -50,15 +63,27 @@ const { title, meta_title, description, image, noindex, canonical } = - - - diff --git a/tailwind.config.js b/tailwind.config.js index 02aa7b6..042d889 100755 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -8,17 +8,12 @@ let h4 = h5 * font_scale; let h3 = h4 * font_scale; let h2 = h3 * font_scale; let h1 = h2 * font_scale; -let fontPrimary, fontPrimaryType, fontSecondary, fontSecondaryType; + +let fontPrimaryType, fontSecondaryType; if (theme.fonts.font_family.primary) { - fontPrimary = theme.fonts.font_family.primary - .replace(/\+/g, " ") - .replace(/:[ital,]*[ital@]*[wght@]*[0-9,;]+/gi, ""); fontPrimaryType = theme.fonts.font_family.primary_type; } if (theme.fonts.font_family.secondary) { - fontSecondary = theme.fonts.font_family.secondary - .replace(/\+/g, " ") - .replace(/:[ital,]*[ital@]*[wght@]*[0-9,;]+/gi, ""); fontSecondaryType = theme.fonts.font_family.secondary_type; } @@ -75,8 +70,8 @@ module.exports = { h6: h6 + "rem", }, fontFamily: { - primary: [fontPrimary, fontPrimaryType], - secondary: [fontSecondary, fontSecondaryType], + primary: ["var(--font-primary)", fontPrimaryType], + secondary: ["var(--font-secondary)", fontSecondaryType], }, }, },