每个Jekyll布局有多个内容
如何在同一帖子中指定两个不同的可渲染性 这就是我想要的。我有一篇带有一些屏幕截图的帖子,然后是帖子的主体每个Jekyll布局有多个内容,jekyll,github-pages,Jekyll,Github Pages,如何在同一帖子中指定两个不同的可渲染性 这就是我想要的。我有一篇带有一些屏幕截图的帖子,然后是帖子的主体 --- layout: post title: App Thing --- <-- some screen shots for the top--> <div> <img class="wi5" src=""> <img class="wi5" src=""> <img class="wi5" src=""> &l
---
layout: post
title: App Thing
---
<-- some screen shots for the top-->
<div>
<img class="wi5" src="">
<img class="wi5" src="">
<img class="wi5" src="">
<img class="wi5" src="">
<img class="wi5" src="">
</div>
<-- the main content of the post -->
blah blah blah blah blah
---
布局:邮政
标题:应用程序
---
废话废话废话
我在文章布局中呈现它,它将呈现标题和日期。但是,我希望屏幕截图位于时间和日期上方,以及以下帖子的正文:
---
layout: default
---
{{ screenshots }}
<div class="wi-100 mw65 center db ptl">
<h1 class="">{{ page.title }}</h1>
<p class=""> {{ page.date | date: "%B %-d, %Y" }}</p>
<p class="">
{% if page.author %}
{{ page.author }}
{% endif %}
</p>
{{ content }}
</div>
---
布局:默认值
---
{{截图}
{{page.title}}
{{page.date | date:“%B%-d,%Y”}
{%if page.author%}
{{page.author}}
{%endif%}
{{content}}
有什么办法吗?我使用的是Github页面,所以我也只能使用插件…对于Jekyll来说,两个“内容”区域是不可能的…只有技巧
最简单的解决方案(不使用插件)如下:
---
layout: post
title: App Thing
images:
- screenshot1.jpg
- screenshot2.jpg
---
<-- the main content of the post -->
blah blah blah blah blah
<div>
<img class="wi5" src="screenshot1.jpg">
<img class="wi5" src="screenshot2.jpg">
</div>
然后,更改布局文件中的循环,如下所示:
{% if page.images %}
<div>
{% for image in page.images %}
<img class="{{ image.class }}" src="{{ image.url }}">
{% endfor %}
</div>
{% endif %}
{%if page.images%}
{page.images%中的图像为%1}
{%endfor%}
{%endif%}
生成的HTML:
<div>
<img class="wi5" src="screenshot1.jpg">
<img class="whatever" src="screenshot2.jpg">
</div>
这有用吗
如果你需要做更多的事情,你可以给每个图像添加更多的属性。Hmmm。我喜欢这个。但我关心的是为不同的帖子定制它。一个帖子可能有全景,另一个帖子可能有10幅并排的图片。这就是为什么我喜欢有一个div的想法,我可以控制我想要的任何类。。。
{% if page.images %}
<div>
{% for image in page.images %}
<img class="{{ image.class }}" src="{{ image.url }}">
{% endfor %}
</div>
{% endif %}
<div>
<img class="wi5" src="screenshot1.jpg">
<img class="whatever" src="screenshot2.jpg">
</div>