gpt4 book ai didi

antd - 使用 GatsbyJS 时更改 Antd 的主题

转载 作者:行者123 更新时间:2023-12-04 23:22:07 30 4
gpt4 key购买 nike

这个 GatsbyJS/antd 插件页面 ( https://github.com/bskimball/gatsby-plugin-antd/issues/2 ) 使得在使用 GatsbyJS 时似乎有一种方法可以编辑 ant.design (antd) 主题。提供的代码是

plugins: [
{
resolve: 'gatsby-plugin-antd',
options: {
style: true
}
}
]

但没有额外的信息。在哪里可以更改主题原色之类的内容(如所述: https://ant.design/docs/react/customize-theme )。 ant.design 页面 ( https://ant.design/docs/react/customize-theme ) 说通过执行以下操作来更改主要颜色:
"theme": {
"primary-color": "#1DA57A",
},

目前尚不清楚在 GatbsyJS 中将在哪个文件中设置这样的变量。

最佳答案

带有示例的 GitHub 存储库: https://github.com/uciska/gatsby-less-v2 。要使 Antd 工作,必须对三个 Gatsby 文件进行更改。

示例 gastby-config.js:

module.exports = {
siteMetadata: {
title: 'My site'
},
plugins: [
{
resolve: `gatsby-plugin-less`,
options: {
javascriptEnabled: true,
modifyVars: {
'primary-color': '#da3043',
'font-family': 'Arial',
'layout-body-background': '#66ff79'
}
}
}
]
}

示例 gastby-node.js:
exports.onCreateBabelConfig = ({ actions }) => {
actions.setBabelPlugin({
name: 'babel-plugin-import',
options: {
libraryName: 'antd',
style: true
}
})
}

示例 package.json:
{
"name": "gatsby-starter-hello-world",
"description": "Gatsby hello world starter",
"license": "MIT",
"scripts": {
"develop": "gatsby develop",
"build": "gatsby build",
"serve": "gatsby serve"
},
"dependencies": {
"antd": "^3.6.4",
"babel-plugin-import": "^1.8.0",
"gatsby": "next",
"gatsby-plugin-less": "next",
"less": "^3.0.4",
"less-loader": "^4.1.0",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-apollo": "^2.1.11"
}
}

关于antd - 使用 GatsbyJS 时更改 Antd 的主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51831582/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com