Skip to content

Commit e7f424d

Browse files
committed
refactor: change the way font was implemented to localFonts
After doing more research I found out the best way is using the localFont and not use the css file directly
1 parent cb90bd1 commit e7f424d

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/app/globals.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
body {
7070
color: var(--foreground);
7171
background: var(--background);
72-
font-family: "DanaVariableFont";
7372
}
7473

7574
@layer base {

src/app/layout.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
1-
import "../../public/fonts/dana/dana.css";
21
import "./globals.css";
32
import { ThemeProvider } from "@/components/contexts/theme-provider";
43
import type { Metadata } from "next";
4+
import localFont from "next/font/local";
55

66
export const metadata: Metadata = {
77
title: "فرانت چپتر | محلی صمیمی برای گفت و گو",
88
description: "Generated by create next app",
99
};
1010

11+
const danaVF = localFont({
12+
src: [
13+
{
14+
path: "../../public/fonts/dana/DanaVF.woff2",
15+
weight: "100 900",
16+
style: "normal",
17+
},
18+
],
19+
variable: "--font-dana",
20+
display: "swap",
21+
fallback: ["Tahoma", "sans-serif"],
22+
});
23+
1124
export default function RootLayout({
1225
children,
1326
}: Readonly<{
@@ -18,7 +31,7 @@ export default function RootLayout({
1831
lang="fa-IR"
1932
dir="rtl"
2033
style={{ colorScheme: "dark" }}
21-
className="dark"
34+
className={`dark ${danaVF.variable}`}
2235
>
2336
<body className="bg-background antialiased">
2437
<ThemeProvider>{children}</ThemeProvider>

0 commit comments

Comments
 (0)