Skip to content

Commit fe51b9f

Browse files
committed
minor improvement to project template
1 parent 7e4dbb4 commit fe51b9f

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

assets/images/project-default.png

5.49 KB
Loading

layouts/projects/list.html

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@
33
<h1>{{ .Title }}</h1>
44

55
{{ range $index, $project := sort .Pages ".Params.date_end" "desc" }}
6+
67
{{ $img := ( .Resources.GetMatch .Params.featured_image ) }}
7-
{{ $img = $img.Resize "200x webp drawing" }}
8+
{{ if not $img }}
9+
{{ $img = resources.Get .Params.featured_image }}
10+
{{ if not $img }}
11+
{{ $img = resources.Get "images/project-default.png" }}
12+
{{ end }}
13+
{{ end }}
14+
815
<section class="mt-5">
916
<header class="mb-2">
1017
<h2>
@@ -15,9 +22,12 @@ <h2>
1522
<p>{{ .Params.date_start | time.Format "Jan 2006" }} &mdash; {{ .Params.date_end | time.Format "Jan 2006" }}</p>
1623
</header>
1724
<div class="clearfix">
18-
<a href="{{ .Permalink }}" class="">
19-
<img src="{{ $img.Permalink }}" alt="{{ $project.Title }} logo" class="float-md-start me-3 mb-2" height="{{ $img.Height }}" width="{{ $img.Width }}" style="max-width:min(200px, 100vw);">
20-
</a>
25+
{{ if $img }}
26+
{{ $img = $img.Resize "200x webp drawing" }}
27+
<a href="{{ .Permalink }}" class="">
28+
<img src="{{ $img.Permalink }}" alt="{{ $project.Title }} logo" class="float-md-start me-3 mb-2" height="{{ $img.Height }}" width="{{ $img.Width }}" style="max-width:min(200px, 100vw);">
29+
</a>
30+
{{ end }}
2131
<p class="mx-1 text-justify">{{ .Params.summary | markdownify }}</p>
2232
</div>
2333
</section>

layouts/projects/single.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{{ define "main" }}
22

3-
3+
{{ $img := ( .Resources.GetMatch .Params.featured_image ) }}
4+
{{ if not $img }}
5+
{{ $img = resources.Get .Params.featured_image }}
6+
{{ end }}
47

58

69
<main class="flex-fill container post my-4" aria-role="main">
@@ -16,10 +19,12 @@ <h2>{{ .Title }}</h2>
1619

1720
<article class="mt-4">
1821
<header class="mb-4">
19-
<div>
20-
{{ $img := ( .Resources.GetMatch .Params.featured_image ).Resize "200x" }}
21-
<img src="{{ $img.Permalink }}" alt="{{ .Title }} logo" class="me-3 mb-2" height="{{ $img.Height }}" width="{{ $img.Width }}" style="max-width:min(200px, 100vw);" />
22-
</div>
22+
{{ if $img }}
23+
{{ $img = $img.Resize "200x webp drawing" }}
24+
<div>
25+
<img src="{{ $img.Permalink }}" alt="{{ .Title }} logo" class="me-3 mb-2" height="{{ $img.Height }}" width="{{ $img.Width }}" style="max-width:min(200px, 100vw);" />
26+
</div>
27+
{{ end }}
2328
<div>
2429
<h1>{{ .Title }}</h1>
2530
<p>

0 commit comments

Comments
 (0)