Skip to content

Commit

Permalink
refactor: Restructure member rendering
Browse files Browse the repository at this point in the history
Member rendering refactored to use partials and re-use the same code for
both current and former members. Additionally redo the avatar URL
linking to be consistent.
  • Loading branch information
gbdlin committed Jun 20, 2024
1 parent 5ed824a commit 0f7d4e9
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 38 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# website
## Local test

### With docker
`docker compose up`

### Without docker

Install [hugo](https://gohugo.io/), then start the server
```bash
hugo server
Expand Down
10 changes: 10 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
overlays:
image: hugomods/hugo:latest
volumes:
- "./:/src/"
command: [
"hugo", "server", "--disableFastRender", "--bind", "0.0.0.0",
]
ports:
- "1313:1313"
14 changes: 14 additions & 0 deletions layouts/partials/member-image.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .gravatar }}
{{ $avatar := printf "https://gravatar.com/avatar/%s.jpg?s=142" .gravatar }}
{{ $image := resources.GetRemote $avatar}}
<img class="avatar" src="{{ $image.RelPermalink }}" />
{{ else }}
{{ $avatar := printf "avatars/%s.png" .name }}
{{ $image := resources.Get $avatar }}
{{- if $image }}
{{ $image := $image.Process "fit 200x200" }}
<img class="avatar" src="{{ $image.RelPermalink }}" />
{{ else }}
<img class="blank-avatar" src="/blank_avatar.png" alt="No avatar image" />
{{end -}}
{{end -}}
16 changes: 16 additions & 0 deletions layouts/partials/member.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<li>
{{- if .link }}
<a href="{{ .link }}">
{{- partial "member-image" . }}
</a>
{{- else }}
{{- partial "member-image" . }}
{{ end -}}
<h4 class="member-name">
{{- if .link }}<a href="{{ .link }}"><u>{{ .name }}</u></a>{{ else }}{{ .name }}{{ end -}}
</h4>
<div class="member-tags">
{{- range .tags }}<span class="tag tag-{{ . }}">{{ . }}</span>{{ end -}}
</div>
<p class="member-desc">{{ .bio | markdownify }}</p>
</li>
40 changes: 2 additions & 38 deletions layouts/shortcodes/memberlist.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,15 @@

<ul class="member-list">
{{ range .Site.Data.members.current }}
<li>
{{- if .gravatar }}
<a href="{{ .link }}">
{{ $avatar := printf "https://gravatar.com/avatar/%s.jpg?s=142" .gravatar }}
{{ $image := resources.GetRemote $avatar}}
<img class="avatar" src="{{ $image.RelPermalink }}" />
</a>
{{ else }}
{{ $avatar := printf "avatars/%s.png" .name }}
{{ $image := resources.Get $avatar }}
{{- if $image }}
{{ $image := $image.Process "fit 200x200" }}
<a href="{{ .link }}">
<img class="avatar" src="{{ $image.RelPermalink }}" />
</a>
{{ else }}
<img class="blank-avatar" src="/blank_avatar.png" alt="No avatar image" />
{{end -}}
{{end -}}
<h4 class="member-name">
{{- if .link }}<a href="{{ .link }}"><u>{{ .name }}</u></a>{{ else }}{{ .name }}{{ end -}}
</h4>
<div class="member-tags">
{{- range .tags }}<span class="tag tag-{{ . }}">{{ . }}</span>{{ end -}}
</div>
<p class="member-desc">{{ .bio | markdownify }}</p>
</li>
{{ partial "member" . }}
{{ end }}
</ul>

<details>
<summary class="former-details-header member-former-header">Former</summary>
<ul class="member-list">
{{ range .Site.Data.members.former }}
<li>
<h4 class="member-name">
{{- if .link }}<a href="{{ .link }}">{{ .name }}</a>{{ else }}{{ .name }}{{ end -}}
</h4>
{{/*
<div class="member-tags">
{{- range .tags }}<span class="tag tag-{{ . }}">{{ . }}</span>{{ end -}}
</div>
<p class="member-desc">{{ .bio | markdownify }}</p>
*/}}
</li>
{{ partial "member" . }}
{{ end }}
</ul>
</details>

0 comments on commit 0f7d4e9

Please sign in to comment.