首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否有可能覆盖盖茨比主题博客的字体?

是否有可能覆盖盖茨比主题博客的字体?
EN

Stack Overflow用户
提问于 2020-04-13 07:38:37
回答 1查看 599关注 0票数 1

我正在使用盖茨比主题-博客,并希望使用默认的“蒙特塞拉特”以外的字体,这是与"Wordpress 2016“主题。

如果可能的话,我想将字体更改为"Work Sans",这是"fairyGate“主题用于标题的。

盖茨比主题中的阴影中,我知道如何在我的项目下创建文件来替换原始文件。但是,所有方法都失败了,Posts页面中的标题保持为Montserrat

以下是我尝试过的:

  1. 安装主题及其依赖的字体:
代码语言:javascript
复制
// package.json
{
  "dependencies": {
    "@theme-ui/typography": "^0.3.0", // to use `toTheme` method
    "typeface-work-sans": "^0.0.72", // the font I'd like to use
    "typography-theme-fairy-gates": "^0.16.19"
  }
}
  1. 创建文件以隐藏原始排版:
代码语言:javascript
复制
// my-project/src/gatsby-theme-blog/gatsby-plugin-theme-ui/typography.ts

import "typeface-work-sans"

import { toTheme } from "@theme-ui/typography"
import fairyGates from "typography-theme-fairy-gates"

export default toTheme(fairyGates)
代码语言:javascript
复制
// my-project/src/gatsby-theme-blog/gatsby-plugin-theme-ui/index.ts


/* I duplicate most codes in original gatsby-plugin-theme-ui/index.js 
   intentionally to avoid other possible failing factors */

import merge from "deepmerge"
import typography from "gatsby-theme-blog/src/gatsby-plugin-theme-ui/typography"
import colors from "gatsby-theme-blog/src/gatsby-plugin-theme-ui/colors"
import styles from "gatsby-theme-blog/src/gatsby-plugin-theme-ui/styles"
import prism from "gatsby-theme-blog/src/gatsby-plugin-theme-ui/prism"

export default merge(typography, {
  initialColorMode: `light`,
  colors,
  fonts: {
    heading: `Work Sans, sans-serif`, // <- Changing font here doesn't work as expected!
    monospace: `Consolas, Menlo, Monaco, source-code-pro, Courier New, monospace`,
  },
  sizes: {
    container: 672,
  },
  styles,
  prism,
})

任何建议都是非常感谢的!

EN

回答 1

Stack Overflow用户

发布于 2020-04-13 18:05:21

  1. 创建一个布局文件并将所有页面包装在其中。像这样的东西可以起作用
  2. 使用JS中的CSS对样式或类似的样式进行范围调整,您可以指定字体样式,并以范围和模块化的方式覆盖css样式。
  3. 使用Gatsby插件google字体将您选择的字体
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61183408

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档