我对 Hugo 和 Netlify 都是新手,所以我可能只是做错了。
我已经使用Hugo、Galleria插件成功地构建和部署了一个带有画廊的站点,并部署到Netlify这一切都奏效了。但是,我想尝试使用Netlify CMS,并且正在努力设置它来处理画廊功能(它只适合写一篇文字帖子)
我不确定这是否是 Netlify CMS 的限制,或者我正在以不适合静态站点的方式制作画廊。
为了在 Hugo 中实现画廊,我在每篇文章的开头都做了以下事情:
+++
date = "2017-02-13T23:17:09+01:00"
summary = "In which I fail to RTFM, visit a Lamasery, and eat a lot of fruit."
tags = []
title = "China 2017: Day 11"
[[galleria]]
imgSrc = "../images/china/11/Lama-Temple.JPG"
imgTitle = "Hall In The Lama Temple"
imgDesc = "One of the main halls of the Lama Temple."
[[galleria]]
imgSrc = "../images/china/11/Octagonal-Hall.JPG"
imgTitle = "Octagonal Hall"
imgDesc = "An octagonal building just inside the entrance of the Lama Temple"
.
.
.
+++
然后在布局页面中:
{{ if isset .Params "galleria" }}
<div class="galleria">
{{ range .Params.galleria}}
<img src="{{ .imgSrc }}" alt="{{ .imgTitle }}" data-title="{{ .imgTitle }}" data-description="{{ .imgDesc }}">
{{ end }}
</div>
{{ end }}
在 Netlify CMS 设置中,我尝试添加一个对象小部件:
- name: "galleria"
label: "Gallery"
widget: "object"
optional: true
fields:
- {label: "Title", name: "imgTitle", widget: "string"}
- {label: "Gallery Image", name: "imgSrc", widget: "image"}
- {label: "Description", name: "imgDesc", widget: "string"}
我有两个问题:
(i) 对象出现,但当然只有一次。我将如何设置它以允许我输入任意数量的图像?
(ii) 在构建时,我收到一个错误:ERROR 2017/05/28 22:37:20 Error while rendering "page": template: _default/single.html:23:15: executing "_default/single.html" at <.imgSrc>: can't evaluate field imgSrc in type interface {}
因此,即使尝试将一张图像(和相关数据)放入帖子中,我似乎也做错了。