小编Daw*_*ahl的帖子

Storybook 问题:本地字体未加载 - Next 13 + Tailwind + Storybook 7

最初的问题:

我的设置一切正常,但我有一个问题:我的自定义字体未加载到 Storybook 中。

(我的主要问题是关于缺少的CSS变量,请到底部查看它。我只是发布所有代码以供参考。)

部分目录结构:

截图 2023-09-02 11 29 26

这是我在“app/(site)/layout.tsx”中使用 Next 修复本地字体的地方:

布局.tsx

import "../styles/globals.css"
import type { Metadata } from "next"
import localFont from "@next/font/local"
import Header from "@/app/components/Header"
import Footer from "@/app/components/Footer"
import { getCachedClient } from "@/sanity/lib/getClient"
import SiteConfigQuery from "@/sanity/queries/site-config/siteConfigQuery"
import { MobileDrawer } from "../components/MobileDrawer"

const tTFirs = localFont({
    src: [
        {
            path: "../../public/fonts/TypeType - TT Firs Regular.otf",
            weight: "300"
        },
        {
            path: "../../public/fonts/TypeType - TT Firs Medium.otf",
            weight: "400"
        },
        {
            path: "../../public/fonts/TypeType - TT Firs Medium …
Run Code Online (Sandbox Code Playgroud)

fonts next.js storybook tailwind-css

7
推荐指数
1
解决办法
2273
查看次数

标签 统计

fonts ×1

next.js ×1

storybook ×1

tailwind-css ×1