-
Notifications
You must be signed in to change notification settings - Fork 325
/
Copy pathauthor_link.html
15 lines (14 loc) · 980 Bytes
/
author_link.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{{/* This partial creates a link to an author page. Its main purpose is to
resolve variant spellings to canonical entries (as only canonical entries
have author pages), while preserving the variant spelling in the link
text.
This partial expects a dictionary with the following entries:
- ctx: The page context
- person: A dict with key "id" (the ID of the person to link to, e.g., "hector-martinez-alonso"), and optional key "full" (a variant spelling)
- class (optional): CSS classes for the link
*/}}
{{ $id_first_letter := slicestr .person.id 0 1 }}
{{ $entry := index .ctx.Site.Data.people $id_first_letter .person.id }}
{{ $name_first_letter := slicestr $entry.slug 0 1 }}
{{ $link_to := printf "/people/%s/%s/%s.md" $name_first_letter $entry.slug .person.id }}
<a href="{{ relref .ctx $link_to }}"{{ with .class }} class="{{ . }}"{{ end }}>{{ if isset .person "full" }}{{ .person.full }}{{ else }}{{ $entry.full }}{{ end }}</a>