从输出设置为 true 的集合生成的页面布局
Layout for pages generated from a collection with output set to true
我在 Jekyll 中构建了一个风格指南,并为每个组件设置了一个集合。它只使用 front-matter 来显示有关样式的数据。文件可能如下所示:
---
title: "Button Big Fixed"
type: interactive elements
description: "A big button with a fixed height."
code:
html: |
<button class="expanderBtn icon">Button</button>
css: |
.test {
font-size: 20px;
text-align: center;
}
colors:
- name: Brand Blue
hex: "#006CFF"
notes: Used as the background
- name: Hover
hex: "#7FB5FF"
notes: Brand Blue with 50% opacity
- name: Clicked
hex: "#4091FF"
notes: Brand Blue with 75% opacity
- name: Text
hex: "#000000"
notes: Text should be black for best legibility
---
现在,对于永久链接功能,我想使用 output: true。但是,生成的文档是空的,因为我只使用了front matter
有什么方法可以设置自定义模板或类似的东西,这样我就可以在输出生成的页面上渲染前面的内容:true?
您可以为 _config.yml 中的每个集合添加默认模板。这看起来像这样:
defaults:
- scope:
path: ''
values:
layout: 'page'
- scope:
path: ''
type: 'guides'
values:
layout: 'guide'
意思是:除了合集'guides'以外的所有内容都使用_layouts目录下的page.html文件。对于 'guides',您应该使用 guide.html。在您的 _layouts 文件夹中创建此文件。在这个 guide.html 文件中,您可以使用以下方式调用部分 frontmatter:
page.title
page.description
page.etc
祝你好运!
我在 Jekyll 中构建了一个风格指南,并为每个组件设置了一个集合。它只使用 front-matter 来显示有关样式的数据。文件可能如下所示:
---
title: "Button Big Fixed"
type: interactive elements
description: "A big button with a fixed height."
code:
html: |
<button class="expanderBtn icon">Button</button>
css: |
.test {
font-size: 20px;
text-align: center;
}
colors:
- name: Brand Blue
hex: "#006CFF"
notes: Used as the background
- name: Hover
hex: "#7FB5FF"
notes: Brand Blue with 50% opacity
- name: Clicked
hex: "#4091FF"
notes: Brand Blue with 75% opacity
- name: Text
hex: "#000000"
notes: Text should be black for best legibility
---
现在,对于永久链接功能,我想使用 output: true。但是,生成的文档是空的,因为我只使用了front matter
有什么方法可以设置自定义模板或类似的东西,这样我就可以在输出生成的页面上渲染前面的内容:true?
您可以为 _config.yml 中的每个集合添加默认模板。这看起来像这样:
defaults:
- scope:
path: ''
values:
layout: 'page'
- scope:
path: ''
type: 'guides'
values:
layout: 'guide'
意思是:除了合集'guides'以外的所有内容都使用_layouts目录下的page.html文件。对于 'guides',您应该使用 guide.html。在您的 _layouts 文件夹中创建此文件。在这个 guide.html 文件中,您可以使用以下方式调用部分 frontmatter:
page.title
page.description
page.etc
祝你好运!