首页 文章

Jekyll动态地在帖子布局中包含新的部分?

提问于
浏览
1

我've just created a portfolio collection in Jekyll and I'已设法在我的 single-project.html 布局上包含额外的 html sections ,并使用简单的Liquid语法 .

这些额外的html部分得到了拯救,因此单个项目的页面内容不会显式地驻留在为 {{ content }} 变量定义的唯一容器/包装器中 .

所以(在视觉上说)我可以将任何html内容放在 <section></section> 中并相应地设置样式,以便 single-project.html 布局可以使用全宽容器/元素来丰富等等 . 但是,我坚持只在上面注入全宽内容的可能性,而在{}变量下面 .

是否有解决方法来实现动态布局结构以在Jekyll中包含页面上的部分?


project.md 文件中

对于每个单项目我希望有更多的html部分,我在's front-matter the names of the html files I' d {% include %} 中定义 single-project.html 布局 .

---
### Project Details
layout: project
title: Cards Mockup project

# Project Extra Sections
sections_top:
  sections: ['section-intro.html', 'section-services-provided.html']
#
sections_bottom:
  sections: ['section-fullwidth-figure.html']
---

single-project.html 布局中

我有条件地包括前面提供的html部分,每个文档的前端问题如下:

<div class="main-container">
{% if page.sections_top %}
<div class="container-fluid no-pad">
{% assign sections_top = page.sections_top['sections'] %}
 {% for section in sections_top %}
  {% include {{ section }} %}
 {% endfor %}
</div>
{% endif %}


<!-- Section main content -->
<section class="article-body">

<div class="container">
 <div class="row">
  <div class="col-sm-12">
  {{ content }}
  </div>
 </div>
</div><!-- end .container -->                 

</section><!-- end section main content -->

{% if page.sections_bottom %}
<div class="container-fluid no-pad">
{% assign sections_bottom = page.sections_bottom['sections'] %}
 {% for section in sections_bottom %}
  {% include {{ section }} %}
 {% endfor %}
</div>
{% endif %}

</div><!-- end .main-container -->

这是一个截图:https://cloudup.com/cK-_jbTdTqU(全宽图像之间的所有内容都是{},全宽图像是html部分 .

1 回答

相关问题