我正在尝试制作一个多语言网站,但遇到了一些问题。
预期行为:
语言自动更改取决于浏览器语言
用户可以切换语言
我看到gatsby-plugin-i18n并遵循了如何使用它的建议,但我的问题是我通过 Netlify CMS 自动创建页面并且无法根据需要获得正确的文件名:page.lang.md
我正在获取page-lang.md.
我想知道是否有人已经有了工作方法,或者可以告诉我我做错了什么,可能gatsby-plugin-i18n根本不适合这个堆栈
提前致谢
我正在使用 gatsby 和 Netlify CMS 构建一个站点。我使用了 Gatsby Site Starter。
我不断收到“文件”类型的“GraphQL 错误字段”图像,必须选择子字段。您的意思是“图像 { ... }”吗?尝试部署到 Netlify 时出错。一切都在本地主机上完美运行,但图像似乎有些失败。我查看了 Netlify CMS 页面上提供的示例,发现有人具有完全相同的设置,一个列表小部件(充当画廊),里面有一个图像和描述,here。
配置文件
backend:
name: git-gateway
repo: grantballmer/gatsby-starter-netlify-cms
branch: master
media_folder: static/img
public_folder: /img
collections:
- name: "gallery"
label: "Gallery"
folder: "src/pages/services"
create: true
fields:
- { label: "Template Key", name: "templateKey", widget: "hidden", default: "gallery" }
- {label: "Title", name: "title", widget: "string"}
- label: "Grid"
name: "grid"
widget: "list"
fields:
- {label: "Image", name: "image", widget: "image"}
- {label: …Run Code Online (Sandbox Code Playgroud) 我正在使用 Netlify CMS。我想将轮播的所有幻灯片导入到我的组件中。我制作了一个名为“滑块”的集合,并添加了一些幻灯片。这创建了两个 markdown 文件(每张幻灯片一个)public/content/slider/。我想将它们全部导入到一个可迭代对象中,以便我可以构建轮播。
因为我为 markdown 文件设置了 webpack 加载器,所以我可以毫无问题地导入单个 markdown 文件,如下所示:
import post from '../public/content/posts/[post name].md
但是当我尝试使用require.context、require-context或 import 时fs,效果并不好。所以我决定尝试从getStaticProps. 但__dirname在getStaticPropsis中/,我的计算机文件系统的根目录。
所有getStaticProps示例都使用数据获取。我缺少一些信息。如何导入/slides/文件夹中的所有markdown文件?
我正在尝试将 Gatsby starter 与 Netlify CMS 一起使用。https://github.com/stackrole-dev/gatsby-starter-foundation
\n\n我完全按照说明进行操作,但在启用 Git Gateway 后,当我尝试以管理员身份登录时,我遇到了此错误消息。
\n\nYour Git Gateway backend is not returning valid settings. Please make sure it is enabled.\nRun Code Online (Sandbox Code Playgroud)\n\n我不知道为什么它不起作用。
\n\n我的config.yml是
backend:\n name: git-gateway\n commit_messages:\n create: \'Create {{collection}} \xe2\x80\x9c{{slug}}\xe2\x80\x9d\'\n update: \'Update {{collection}} \xe2\x80\x9c{{slug}}\xe2\x80\x9d\'\n delete: \'Delete {{collection}} \xe2\x80\x9c{{slug}}\xe2\x80\x9d\'\n uploadMedia: \'[skip ci] Upload \xe2\x80\x9c{{path}}\xe2\x80\x9d\'\n deleteMedia: \'[skip ci] Delete \xe2\x80\x9c{{path}}\xe2\x80\x9d\'\n\nlocal_backend: true # run npx netlify-cms-proxy-server for local testing\n\nmedia_folder: "static/assets" \npublic_folder: "/assets" \n\ncollections:\nRun Code Online (Sandbox Code Playgroud)\n Gatsby 和 Netlify CMS 运行良好一段时间,但现在尝试运行时失败gatsby develop。出现“JavaScript 堆内存不足”错误。
每个 npm 都会更新,我已经尝试export NODE_OPTIONS=--max_old_space_size=4096过一些 GitHub 问题线程提到的。
有没有人幸运地使用OAUTH从Netlify CMS向GB进行身份验证,但没有使用Netlify API?如果是这样,您使用了什么?我想使用我的域进行身份验证,但是我不确定应该为此使用哪个API或程序包。我在学。任何帮助将不胜感激。
从我的降价文件中index.md,...
---
templateKey: home-page/index
image1: /img/City-Picture.jpg
---
Run Code Online (Sandbox Code Playgroud)
...我想对...中image1的graphql此处进行优化templates/index.js
export const homePageQuery = graphql`
query HomePage($id: String!) {
markdownRemark(id: { eq: $id }) {
frontmatter {
welcome_description
image1 {
childImageSharp {
sizes(maxWidth: 590) {
...GatsbyImageSharpSizes
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是我在终端中收到此错误...
GraphQL Error Field "image1" must not have a selection since type "String" has no subfields.
2 | query HomePage($id: String!) {
3 | markdownRemark(id: { eq: $id }) {
4 | frontmatter …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试将yaml文件中的绝对路径解析为相对路径,以便可以在gatsby中使用graphql进行查询。绝对路径是从netlify-cms提供的。
当将相同的路径放置在md文件中并用于gatsby-remark-relative-images将其转换为相对路径时,它完全没有问题,但是相同的内容不适用于yaml。
将图像文件放入其中,static/img/cms提供的路径为/img/xxx.jpg
src / data / pages / index.yaml
page: index
slider:
- image: /img/1_new.jpg
url: ""
- image: /img/2_new.jpg
url: ""
- image: /img/3_new.jpg
url: ""
Run Code Online (Sandbox Code Playgroud)
gatsby-config.js
module.exports = {
// ...
plugins: [
// ...
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/src/data`,
name: 'data',
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
path: `${__dirname}/static/img`,
name: 'uploads',
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
path: `${__dirname}/src/pages`,
name: 'pages',
},
},
{
resolve: 'gatsby-source-filesystem',
options: …Run Code Online (Sandbox Code Playgroud) 我有一个相当简单的 Gatsby & Netlify CMS 站点。我无法应付使图像可选。在 Netlify CMS 的情况下,它只是设置一个字段的问题required: false。我如何为 Gatsby 编写查询,以便我不会收到错误“GraphQL 错误字段“图像”必须没有选择,因为“字符串”类型没有子字段。当图像实际上是一个空字符串时,因为它在我的应用程序中不是强制性的?有没有办法解决?
GraphQL 查询图像:
image {
childImageSharp {
fluid(maxWidth: 2048)
...GatsbyImageSharpFluid
}
}
}
Run Code Online (Sandbox Code Playgroud) 从昨天开始,我遇到了一个无法修复或找不到相关信息的错误。我可以在本地构建我的网站,不会出现错误,但是当我尝试在 Netlify 中部署它时,它失败并抛出:
\n8:19:33 AM: \xe2\x80\x8b\n8:19:33 AM: \xe2\x94\x8c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x90\n8:19:33 AM: \xe2\x94\x82 Netlify Build \xe2\x94\x82\n8:19:33 AM: \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x98\n8:19:33 AM: \xe2\x80\x8b\n8:19:33 AM: \xe2\x9d\xaf Version\n8:19:33 AM: @netlify/build 2.0.20\n8:19:33 AM: \xe2\x80\x8b\n8:19:33 AM: \xe2\x9d\xaf Flags\n8:19:33 AM: deployId: 5efc2a7760231502ad0a057d\n8:19:33 AM: mode: buildbot\n8:19:33 AM: \xe2\x80\x8b\n8:19:33 AM: \xe2\x9d\xaf Current directory\n8:19:33 AM: /opt/build/repo\n8:19:33 AM: \xe2\x80\x8b\n8:19:33 AM: \xe2\x9d\xaf Config file\n8:19:33 AM: /opt/build/repo/netlify.toml\n8:19:33 AM: \xe2\x80\x8b\n8:19:33 AM: \xe2\x9d\xaf Context\n8:19:33 AM: production\n8:19:33 AM: \xe2\x80\x8b\n8:19:33 AM: \xe2\x94\x8c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x90\n8:19:33 AM: \xe2\x94\x82 Core internal error \xe2\x94\x82\n8:19:33 AM: \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x98\n8:19:33 AM: \xe2\x80\x8b\n8:19:33 AM: Error message\n8:19:33 AM: Error: Invalid version: "1"\n8:19:33 …Run Code Online (Sandbox Code Playgroud) continuous-deployment gatsby netlify netlify-cms netlify-cli
netlify-cms ×10
gatsby ×8
netlify ×5
reactjs ×4
graphql ×3
javascript ×2
gatsby-image ×1
github ×1
netlify-cli ×1
next.js ×1
node.js ×1
oauth ×1