2020年7月24日金曜日

開発環境

Build Websites With Hugo: Fast Web Development With Markdown (Brian P. Hogan(著)、Pragmatic Bookshelf)のChapter 5(Adding a Blog)、Your Turn 2、4、5.の解答を求めてみる。

portfolio/themes/basic/layouts/_default/category.html

{{ define "main" }}
<h2>{{ .Title }}</h2>
{{ range .Paginator.Pages }}
{{ partial "post_summary.html" .}}
{{end}}
{{template "_internal/pagination.html" . }}
{{end}}

portfolio/themes/basic/layouts/projects/list_with_pagination.html

{{define "main"}}
<h2>{{.Title}}</h2>
{{range .Paginator.Pages }}
{{partial "post_summary.html" . }}
{{end}}
{{template "_internal/pagination.html" . }}
{{end}}

portfolio/content/projects/_index.md

---
title: "Projects"
draft: false
layout: list_with_pagination
---

This is a list of my projects. You can select each project to learn more about each one.

portfolio/themes/basic/layouts/index.html

{{ define "main"}}
<h2>最新</h2>
<section class="post">
 {{ $page := index (where .Site.RegularPages "Type" "in" "posts").ByDate.Reverse 0}}
 <h3>{{ $page.Title }}</h3>
 {{ $page.Summary }}
</section>
<section class="project">
 {{ $page := index (where .Site.RegularPages "Type" "in" "projects").ByDate.Reverse 0}}
 <h3>{{ $page.Title }}</h3>
 {{ $page.Content }}
</section>
{{ .Content }}
{{ end }}

0 コメント:

コメントを投稿