Skip to content

Commit 46d8b5e

Browse files
committed
Support complex apps
1 parent e4242f1 commit 46d8b5e

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

archetypes/default.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ date: {{ .Date }}
55
enableDisqus: true
66
full: false
77
img: ""
8+
tags: []
89
---

exampleSite/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ googleAnalytics = ""
66
title = "Your site title"
77
copyright = ""
88

9+
[taxonomies]
10+
tag = "tags"
11+
912
[params]
1013
googleAutoAds = ""
1114
avatar = "https://openclipart.org/download/103855/tux.svg"

layouts/_default/list.html

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,43 @@
11
{{ define "main" }}
22
<div class="apps-list">
3+
<!-- data/TYPENAME/ITEMNAME/hugo.json-->
4+
{{ $curTypeName := ($.Permalink | path.Dir | path.Split).File }}
5+
<h1>{{- $curTypeName -}}</h1>
6+
{{ range $typeName, $type := .Site.Data }}
7+
{{ if eq $typeName $curTypeName }}
8+
{{ range $itemName, $itemMap := $type }}
9+
{{ $item := $itemMap.hugo }}
10+
{{ $title := $item.title | default $itemName }}
11+
{{ $itemUrl := $item.url | default (print "/" $typeName "/" $itemName | absURL) }}
12+
{{ $imageUrl := $item.image | default (print "/img/no-image.svg" | absURL) }}
13+
<div class="apps-app-item">
14+
<div class="apps-app-icon">
15+
<a href="{{- $itemUrl -}}">
16+
<img src="{{- $imageUrl -}}"/>
17+
</a>
18+
</div>
19+
<div class="apps-app-name">
20+
<a href="{{- $itemUrl -}}">
21+
<h6>{{- $title -}}</h6>
22+
</a>
23+
</div>
24+
</div>
25+
{{ end }}
26+
{{ end }}
27+
{{ end }}
328
{{ range .Pages }}
429
<div class="apps-app-item">
530
<div class="apps-app-icon">
6-
<a href="{{ .Permalink }}">
7-
{{ if or (not (isset .Params "img")) (eq .Params.img "") }}
8-
<img src="{{ .Site.BaseURL }}/img/no-image.svg"/>
9-
{{ else }}
10-
<img src="{{ .Params.img }}"/>
11-
{{ end }}
31+
{{ $title := (.Permalink | path.Dir | path.Split).File }}
32+
{{ $itemUrl := .Permalink }}
33+
{{ $imageUrl := .Params.img | default (print "/img/no-image.svg" | absURL) }}
34+
<a href="{{- $itemUrl -}}">
35+
<img src="{{- $imageUrl -}}"/>
1236
</a>
1337
</div>
1438
<div class="apps-app-name">
15-
<a href="{{ .Permalink }}">
16-
<h6>{{- .Title -}}</h6>
39+
<a href="{{- $itemUrl -}}">
40+
<h6>{{- $title -}}</h6>
1741
</a>
1842
</div>
1943
</div>

0 commit comments

Comments
 (0)