1
Fork 0

Extract box to partial

This commit is contained in:
Jake Howard 2017-04-24 09:06:14 +01:00
parent f1f87aaddd
commit 733bfb46f7
3 changed files with 26 additions and 22 deletions

View file

@ -11,18 +11,7 @@
{{ end }}
<div class="row">
{{ range .Pages.ByTitle }}
<div class="col-sm-6">
<section class="box special">
{{ if .Params.image }}
<span class="image featured"><img src="{{ .Params.image }}" alt="{{ .Title }} featured image" /></span>
{{ end }}
<h3>{{ title .Title }}</h3>
<p>{{ .Summary }}</p>
<ul class="actions">
<li><a href="{{ .Permalink }}" class="button alt">Read More</a></li>
</ul>
</section>
</div>
{{ partial "box.html" . }}
{{ end }}
</div>
</section>

View file

@ -40,21 +40,24 @@
</div>
</section>
<div class="box special">
<h2>Projects</h2>
<div class="row">
{{ range first 6 (where .Data.Pages.ByDate "Kind" "projects") }}
{{ if ne .Section "" }}
{{ partial "box.html" . }}
{{ end }}
{{ end }}
</div>
<h4><a href="/projects/">All Projects</a></h4>
</div>
<div class="box special">
<h2>Recent Posts</h2>
<div class="row">
{{ range first 6 (where .Data.Pages.ByDate "Kind" "page") }}
{{ if ne .Section "" }}
<div class="col-sm-6">
<section class="box special">
<span class="image featured"><img src="{{ .Params.image }}" /></span>
<h3>{{ .Title }}</h3>
<p>{{ .Summary }}</p>
<ul class="actions">
<li><a href="{{ .Permalink }}" class="button alt">Read More</a></li>
</ul>
</section>
</div>
{{ partial "box.html" . }}
{{ end }}
{{ end }}
</div>

12
layouts/partials/box.html Normal file
View file

@ -0,0 +1,12 @@
<div class="col-sm-6">
<section class="box special">
{{ if .Params.image }}
<span class="image featured"><img src="{{ .Params.image }}" alt="{{ .Title }} featured image" /></span>
{{ end }}
<h3>{{ title .Title }}</h3>
<p>{{ .Summary }}</p>
<ul class="actions">
<li><a href="{{ .Permalink }}" class="button alt">Read More</a></li>
</ul>
</section>
</div>