diff options
author | Emiel Hollander <EmielH@users.noreply.github.com> | 2018-10-21 11:51:23 +0300 |
---|---|---|
committer | Emiel Hollander <EmielH@users.noreply.github.com> | 2018-10-21 11:51:23 +0300 |
commit | ffc436900bc174126845ad5fe632d151e16a0ff6 (patch) | |
tree | f4de24c6b076093f96c09278106018222cc203c3 | |
parent | 16c49c87d139b42cf985c1fab69ecdb02206959c (diff) |
Extract summary from list templates into its own layout file
Extract the summary into its own layout file and use the .Render
function to include the summary, which is the same for all list
templates.
-rw-r--r-- | layouts/_default/list.html | 15 | ||||
-rw-r--r-- | layouts/_default/summary.html | 11 | ||||
-rw-r--r-- | layouts/_default/taxonomy.html | 15 | ||||
-rw-r--r-- | layouts/index.html | 15 |
4 files changed, 17 insertions, 39 deletions
diff --git a/layouts/_default/list.html b/layouts/_default/list.html index f25fe6f..5918367 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -3,18 +3,7 @@ <main> <div class="catalogue"> {{ range (.Paginate .Pages).Pages }} - <a href="{{ .Permalink }}" class="catalogue-item"> - <div> - <time datetime="{{ .PublishDate }}" class="catalogue-time">{{ i18n "publishdate" . }}</time> - <h1 class="catalogue-title">{{ .Title }}</h1> - <div class="catalogue-line"></div> - - <p> - {{ if isset .Params "summary" }}{{ .Params.Summary }}{{ else }}{{ .Summary }}{{ end }} - </p> - - </div> - </a> + {{ .Render "summary" }} {{ end }} </div> @@ -30,4 +19,4 @@ </div> </main> -{{ end }}
\ No newline at end of file +{{ end }} diff --git a/layouts/_default/summary.html b/layouts/_default/summary.html new file mode 100644 index 0000000..14f988c --- /dev/null +++ b/layouts/_default/summary.html @@ -0,0 +1,11 @@ +<a href="{{ .Permalink }}" class="catalogue-item"> + <div> + <time datetime="{{ .PublishDate }}" class="catalogue-time">{{ i18n "publishdate" . }}</time> + <h1 class="catalogue-title">{{ .Title }}</h1> + <div class="catalogue-line"></div> + + <p> + {{ if isset .Params "summary" }}{{ .Params.Summary }}{{ else }}{{ .Summary }}{{ end }} + </p> + </div> +</a> diff --git a/layouts/_default/taxonomy.html b/layouts/_default/taxonomy.html index 34fc2fc..c87822e 100644 --- a/layouts/_default/taxonomy.html +++ b/layouts/_default/taxonomy.html @@ -4,18 +4,7 @@ <h1>{{ strings.FirstUpper .Data.Singular }} {{ .Title }}</h1> <div class="catalogue"> {{ range (.Paginate .Pages).Pages }} - <a href="{{ .Permalink }}" class="catalogue-item"> - <div> - <time datetime="{{ .PublishDate }}" class="catalogue-time">{{ i18n "publishdate" . }}</time> - <h1 class="catalogue-title">{{ .Title }}</h1> - <div class="catalogue-line"></div> - - <p> - {{ if isset .Params "summary" }}{{ .Params.Summary }}{{ else }}{{ .Summary }}{{ end }} - </p> - - </div> - </a> + {{ .Render "summary" }} {{ end }} </div> @@ -31,4 +20,4 @@ </div> </main> -{{ end }}
\ No newline at end of file +{{ end }} diff --git a/layouts/index.html b/layouts/index.html index f25fe6f..5918367 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -3,18 +3,7 @@ <main> <div class="catalogue"> {{ range (.Paginate .Pages).Pages }} - <a href="{{ .Permalink }}" class="catalogue-item"> - <div> - <time datetime="{{ .PublishDate }}" class="catalogue-time">{{ i18n "publishdate" . }}</time> - <h1 class="catalogue-title">{{ .Title }}</h1> - <div class="catalogue-line"></div> - - <p> - {{ if isset .Params "summary" }}{{ .Params.Summary }}{{ else }}{{ .Summary }}{{ end }} - </p> - - </div> - </a> + {{ .Render "summary" }} {{ end }} </div> @@ -30,4 +19,4 @@ </div> </main> -{{ end }}
\ No newline at end of file +{{ end }} |