【问题标题】:Using Netlify CMS with Hugo - creating content of Academic Hugo theme将 Netlify CMS 与 Hugo 一起使用 - 创建 Academic Hugo 主题的内容
【发布时间】:2018-05-09 09:10:46
【问题描述】:

我正在尝试将 Netlify CMS 集成到 Academic Hugo 主题中。我想构建一个 config.yml,其中包含用于发布、谈话等的集合。我的问题类似于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 }

非常感谢!

【问题讨论】:

    标签: gallery hugo netlify netlify-cms


    【解决方案1】:

    对于嵌套字段,您将使用listobject 小部件。

    对于“header”,您可以使用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"}
    

    【讨论】:

    • 非常感谢!昨天终于搞定了:- {label: "Header", name: header, widget: object, fields: [ {label: "Featured Image", name: "image", widget: "image", required: false}, {label: "Caption", name: "caption", widget: string}]}
    猜你喜欢
    • 2017-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-06
    • 1970-01-01
    相关资源
    最近更新 更多