我在gatsby网站上使用Netlify CMS.我在我的帖子集合中使用了netlify CMS关系小部件来引用我的作者集合的标题字段,所以...
- {label: "Author", name: "author", widget: "relation", collection: "authors", searchFields: ["title", "firstName", "lastName"], valueField: "title"}
Run Code Online (Sandbox Code Playgroud)
这很好但但是当我在GraphiQL窗口中进行查询时,唯一可用的字段是author,只有一个字符串,如何访问特定作者的所有前端?
随着时间的推移,在Gatsby上进行开发的速度显着放慢-有时需要20到30秒来使热加载器刷新页面。在对页面进行10-20次更新后-它最终总是会遇到以下错误:
error UNHANDLED REJECTION
RuntimeError: memory access out of bounds
- source-map-consumer.js:335 BasicSourceMapConsumer._parseMappings
[frontend]/[gatsby]/[react-hot-loader]/[source-map]/lib/source-map-consumer.js:335:44
- source-map-consumer.js:315 BasicSourceMapConsumer._getMappingsPtr
[frontend]/[gatsby]/[react-hot-loader]/[source-map]/lib/source-map-consumer.js:315:12
- source-map-consumer.js:387 _wasm.withMappingCallback
[frontend]/[gatsby]/[react-hot-loader]/[source-map]/lib/source-map-consumer.js:387:57
- wasm.js:95 Object.withMappingCallback
[frontend]/[gatsby]/[react-hot-loader]/[source-map]/lib/wasm.js:95:11
- source-map-consumer.js:371 BasicSourceMapConsumer.eachMapping
[frontend]/[gatsby]/[react-hot-loader]/[source-map]/lib/source-map-consumer.js:371:16
- source-node.js:87 Function.fromStringWithSourceMap
[frontend]/[gatsby]/[react-hot-loader]/[source-map]/lib/source-node.js:87:24
- webpack.development.js:150 onSourceMapReady
[frontend]/[gatsby]/[react-hot-loader]/dist/webpack.development.js:150:61
- next_tick.js:68 process._tickCallback
internal/process/next_tick.js:68:7
Run Code Online (Sandbox Code Playgroud)
我们的网站大约有250多个静态页面/pages,并以编程方式从*.yml生成的文件中构建约30页netlify-cms。
我怀疑它是与sourcemaps变得非常大-野生的猜测是,它可能是与我们正在做什么gatsby-node.js或cms.js对netlify-CMS管理页-虽然我不知道从哪里开始开始调试这样的问题。任何指针将不胜感激。
我们实施的一个临时解决方案是将Gatsby的默认源映射从更改为cheap-module-eval-source-map,eval从而使热模块重新编译时间从4-6秒减少到1-2秒。但是,我们显然希望拥有性能正常的适当源映射。
// For local development, we disable proper sourcemaps to speed up
// performance.
if (stage === "develop") {
config = { …Run Code Online (Sandbox Code Playgroud) 我正在使用Hugo 的Forty Theme和Netlify CMS,该config.toml文件有一个 Tiles 部分,如下所示:
# Tiles Section
[params.tiles]
enable = true
# Display your showcases here.
[[params.tiles.showcase]]
title =
subtitle =
image =
url =
Run Code Online (Sandbox Code Playgroud)
我希望能够将条目从 CMS 添加到图块部分。如何params.tiles.showcase从 CMS 添加变量?这是我的一个片段config.yml
collections:
- name: "blog"
label: "Blog post"
folder: "post/"
create: true
fields:
- { label: "Title", name: "title" }
- { label: "Publish Date", name: "date", widget: "datetime" }
- { label: "Description", name: "description", widget: "markdown", required: false } …Run Code Online (Sandbox Code Playgroud) 我在自己的服务器上托管我的网站,并使用 Netlify CMS。但是,我仍然希望使用 Netlify 的托管 Identity 和 Git 网关服务,而不是运行我自己的服务。
我在 Gitlab 上有一个 Gatsby 站点部署到 Netlify 并使用 Netlify-CMS。Netlify 可以将站点推送到不同的分支,并将每个分支部署到单独的 url。例如,我当前的站点有一个production部署到的分支example.netlify.com和一个部署到staging--example.netlify.com.
但是,使用 Netlify CMS 更新内容时创建的提交是另一回事。看来(至少开箱即用),Netlify CMS 将始终将更改推送到其配置中定义的生产分支,无论检出哪个分支或站点位于何处:
从文档。
注意:无论您在哪里访问 Netlify CMS——无论是在本地运行、在登台环境中还是在您发布的站点中——它总是会在您配置的分支上的托管存储库(例如,在 GitHub 上)中获取和提交文件您的 Netlify CMS config.yml 文件。这意味着在管理 UI 中获取的内容将与存储库中的内容匹配,这可能与您本地运行的站点不同。这也意味着使用管理 UI 保存的内容将直接保存到托管存储库,即使您在本地或在暂存中运行 UI。
来自config.ymlNetlify CMS 使用的项目配置 ( ):
backend:
name: git-gateway
branch: production
Run Code Online (Sandbox Code Playgroud)
因此,目前我可以更改站点的结构并使它们仅在登台时可用,但是没有机制可以更改内容并使它们仅在本地或仅在登台时可用。
我可以看到的一种选择是为config.yml每个部署部署一个不同的文件(并在本地使用一个单独的文件),因此在本地使用 CMS 时,我将分支设置为dev,在登台和生产中,我将分支设置为staging和production分别。假设通过Netlify-CMS编辑被隔离的内容的位置,这应该可以很容易地从促进内容的变化staging来production。
这是最好的方法吗?
我正在尝试gatsby-plugin-netlify-cms与 Gatsby typescript 集成,每次尝试构建网站时,都会收到以下错误消息。
“您可能需要适当的加载程序来处理此文件类型,目前没有配置加载程序来处理此文件。”
我的gatsby-config.js文件写如下,
module.exports = {
/* Your site config here */
plugins: [
`gatsby-plugin-styled-components`,
{
resolve: `gatsby-plugin-netlify-cms`,
options: {
modulePath: `${__dirname}/src/cms/cms.ts`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `markdown-pages`,
path: `${__dirname}/src/pages`,
},
},
`gatsby-plugin-sharp`,
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 512,
},
},
],
},
},
`gatsby-plugin-netlify`,
],
};
Run Code Online (Sandbox Code Playgroud)
我能够让 Typescript 为我的项目的其余部分工作,但只有当我尝试修改预览模板时,它才开始失败。具体来说,当我编写以下代码时,一切都崩溃了gatsby-plugin-netlify-cms。
options: {
modulePath: `${__dirname}/src/cms/cms.ts`,
},
Run Code Online (Sandbox Code Playgroud)
为什么我收到错误消息?
我想在我的Jekyll网站上使用Netlify CMS,我有这样的布局:
{% for skills in page.skills %}
<div class="guide-skill">
<div class="guide-skill-fill">
{% for i in (1..15) %}
<div class="{% if skills.levels contains i %}fill{% endif %} skill-check"><p>{{ i }}</p></div>
{% endfor %}
</div>
</div>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
以及我在使用此布局的文本编辑器中编写的页面的前端问题:
skills:
- levels:
- 1
Run Code Online (Sandbox Code Playgroud)
代码工作正常,fill类正确添加.
但是当我使用Netlify CMS和列表小部件时,它会将字符串而不是数字返回到levels列表中,如下所示:
skills:
- levels:
- '1'
Run Code Online (Sandbox Code Playgroud)
所以代码不起作用,如何让它返回数字?
i,但它给了我一个错误valueType : "int",没用 - label: "Hero Skills"
name: "skills"
widget: "list"
required: false
fields:
- {label: …Run Code Online (Sandbox Code Playgroud) 在站点上添加netlify cms时,如何将子弹显示在graphql中?我有一个博客文章集,除了子弹外,所有内容都显示出来:
backend:
name: git-gateway
branch: master # Branch to update (optional; defaults to master)
media_folder: static/images
public_folder: /images
collections:
- name: "blog"
label: "Blog"
folder: "content/blogPost"
create: true
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
fields: # The fields for each document, usually in front matter
- { label: "Layout", name: "layout", widget: "hidden", default: "blog" }
- { label: "Title", name: "title", widget: "string" }
- { label: "Publish Date", name: "date", widget: "datetime" }
- { label: "Featured Image", name: "thumbnail", widget: …Run Code Online (Sandbox Code Playgroud) 我有一个react.js 应用程序,我想添加netlify CMS 后端。我按照此处的设置教程进行操作: https: //www.netlifycms.org/docs/add-to-your-site/,但是当我导航到 mysite/admin 时,我只是得到了我的网站。我改变了我的react-router和netlify_redirect文件,并尝试将脚本标签放入正文中,就像这个repo所做的那样: https: //github.com/Jinksi/netlify-cms-react-starter,但现在我只是出现白屏。Jinksi 似乎不遗余力地使用头盔等来完成这项工作。在 netlifyCMS 网站上有使用 Gatsby 等的示例,但没有一个使用纯 React。目前有没有一种简单的方法可以做到这一点?或者我应该使用 Gatsby.js 重写我的网站?
这是我第一次使用Gatsby v2。我有一个由netlify cms创建的test.md文件,正如您在上面的文件系统中看到的那样,该文件位于blog文件夹中。
我也可以在上面的浏览器中使用GraphiQL查询数据。
我得到了一个博客文章列表(1),该列表是一个链接,但没有生成要转到的页面。运行时gatsby build出现错误。
错误为页面构建静态HTML失败
6 | }) {
7 | const { markdownRemark } = data // data.markdownRemark holds our post data
> 8 | const { frontmatter, html } = markdownRemark
| ^
9 | return (
10 | <div className="blog-post-container">
11 | <div className="blog-post">
Run Code Online (Sandbox Code Playgroud)
WebpackError:TypeError:无法读取null的属性“ frontmatter”
我遍历了github问题,并尝试在VSCode中进行调试,但没有运气...
以下是相关文件。
gatsby-config.js
module.exports = {
siteMetadata: {
title: `simco-cms`,
},
plugins: [
`gatsby-plugin-netlify-cms`,
`gatsby-transformer-remark`,
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/blog`,
name: "markdown-pages",
},
},
], …Run Code Online (Sandbox Code Playgroud) netlify-cms ×10
netlify ×7
gatsby ×5
hugo ×1
javascript ×1
jekyll ×1
reactjs ×1
typescript ×1
webpack ×1