我正在尝试将Netlify CMS整合到Academic Hugo主题中。我想构建一个config.yml,其中包含post,talks等集合。我的问题类似于this one。我能够配置每个帖子的一些字段,但我无法包含[]:
中包含的变量+++
title = "Academic: the website designer for Hugo"
date = 2016-04-20T00:00:00
lastmod = 2018-01-13T00:00:00
draft = false
tags = ["academic"]
summary = "Create a beautifully simple website or blog in under 10 minutes."
[header]
image = "headers/getting-started.png"
caption = "Image credit: [**Academic**](https://github.com/gcushen/hugo-
academic/)"
[[gallery_item]]
album = "1"
image = "https://raw.githubusercontent.com/gcushen/hugo-
academic/master/images/theme-default.png"
caption = "Default"
+++
请,任何config.yml都可以输出这种md?
非常感谢你的帮助!
更新:
最后我能够做到这一点,这是我遇到问题的另一种情况:
+++
# About/Biography widget.
widget = "about"
active = true
date = 2016-04-20T00:00:00
# Order that this section will appear in.
weight = 5
# List your academic interests.
[interests]
interests = [
"Artificial Intelligence",
"Computational Linguistics",
"Information Retrieval"
]
# List your qualifications (such as academic degrees).
[[education.courses]]
course = "PhD in Artificial Intelligence"
institution = "Stanford University"
year = 2012
[[education.courses]]
course = "MEng in Artificial Intelligence"
institution = "Massachusetts Institute of Technology"
year = 2009
[[education.courses]]
course = "BSc in Artificial Intelligence"
institution = "Massachusetts Institute of Technology"
year = 2008
+++
这是解决方案,如果它可以帮助某人:
- file: "content/home/about.md"
label: "About"
name: "about"
fields:
- {label: "Widget (Don't modify)", name: "widget", widget: "string", default: "about"}
- {label: "Active", name: "active", widget: "boolean", default: true }
- {label: "Date", name: "date", widget: "datetime" }
- {label: "Weight", name: weight, default: 5}
- {label: "Interests", name: interests, widget: object, fields: [
{label: "Interests list", name: "interests", widget: "list",
default: ["Artificial Intelligence"]}]}
- {label: "Education", name: "education", widget: "object", fields: [
{label: "courses", name: "courses", widget: "list", fields: [
{label: Course, name: course , widget: string},
{label: Institution, name: institution, widget: string},
{label: Year, name: year, default: 2010}]}]}
- { label: "Body", name: "body", widget: "markdown", required: false }
非常感谢!
答案 0 :(得分:2)
对于嵌套字段,您将使用list
或object
小部件。
对于“标题”,您可以使用Netlify CMS object widget,对于“gallery_item”,您可以使用list widget。
示例:
- label: "Header Settings"
name: "header"
widget: "object"
fields:
- {label: "Image", name: "image", widget: "image"}
- {label: "Caption", name: "caption", widget: "markdown"}