Skip to content

Commit 1c757f4

Browse files
mriggerclaude
andcommitted
Add native name support to people and author pages
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
1 parent 4dbfc07 commit 1c757f4

3 files changed

Lines changed: 176 additions & 0 deletions

File tree

content/authors/yuancheng-jiang/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
# Display name
33
title: Yuancheng Jiang
4+
native_name: 蒋远程
45

56
# Is this the primary user of the site?
67
superuser: false
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{{ $ := .root }}
2+
{{ $page := .page }}
3+
4+
{{ $author := "" }}
5+
{{ if .author }}
6+
{{ $author = .author }}
7+
{{ else }}
8+
{{ $author = $page.Params.author }}
9+
{{end}}
10+
11+
{{ $person_page_path := (printf "/authors/%s" $author) }}
12+
{{ $person_page := site.GetPage $person_page_path }}
13+
{{ if not $person_page }}
14+
{{ errorf "Could not find an author page at `%s`. Please check the value of `author` in your About widget and create an associated author page if one does not already exist. See https://wowchemy.com/docs/page-builder/#about " $person_page_path }}
15+
{{end}}
16+
{{ $person := $person_page.Params }}
17+
{{ $avatar := ($person_page.Resources.ByType "image").GetMatch "*avatar*" }}
18+
{{ $avatar_shape := site.Params.avatar.shape | default "circle" }}
19+
20+
<!-- About widget -->
21+
<div class="row">
22+
<div class="col-12 col-lg-4">
23+
<div id="profile">
24+
25+
{{ if site.Params.avatar.gravatar }}
26+
<img class="avatar {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="https://s.gravatar.com/avatar/{{ md5 $person.email }}?s=270')" alt="{{$person_page.Title}}">
27+
{{ else if $avatar }}
28+
{{ $avatar_image := $avatar.Fill "270x270 Center" }}
29+
<img class="avatar {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="{{ $avatar_image.RelPermalink }}" alt="{{$person_page.Title}}">
30+
{{ end }}
31+
32+
<div class="portrait-title">
33+
<h2>{{ $person_page.Title }}{{ with $person.native_name }}<br>({{ . }}){{ end }}</h2>
34+
{{ with $person.role }}<h3>{{ . | markdownify | emojify }}</h3>{{ end }}
35+
36+
{{ range $person.organizations }}
37+
<h3>
38+
{{ with .url }}<a href="{{ . }}" target="_blank" rel="noopener">{{ end }}
39+
<span>{{ .name }}</span>
40+
{{ if .url }}</a>{{ end }}
41+
</h3>
42+
{{ end }}
43+
</div>
44+
45+
<ul class="network-icon" aria-hidden="true">
46+
{{ range $person.social }}
47+
{{ $pack := or .icon_pack "fas" }}
48+
{{ $pack_prefix := $pack }}
49+
{{ if in (slice "fab" "fas" "far" "fal") $pack }}
50+
{{ $pack_prefix = "fa" }}
51+
{{ end }}
52+
{{ $link := .link }}
53+
{{ $scheme := (urls.Parse $link).Scheme }}
54+
{{ $target := "" }}
55+
{{ if not $scheme }}
56+
{{ $link = .link | relLangURL }}
57+
{{ else if in (slice "http" "https") $scheme }}
58+
{{ $target = "target=\"_blank\" rel=\"noopener\"" }}
59+
{{ end }}
60+
<li>
61+
<a href="{{ $link | safeURL }}" {{ $target | safeHTMLAttr }} aria-label="{{ .icon }}">
62+
<i class="{{ $pack }} {{ $pack_prefix }}-{{ .icon }} big-icon"></i>
63+
</a>
64+
</li>
65+
{{ end }}
66+
</ul>
67+
68+
</div>
69+
</div>
70+
<div class="col-12 col-lg-8">
71+
72+
{{/* Only display widget title in explicit instances of about widget, not in author pages. */}}
73+
{{ if and $page.Params.widget $page.Title }}<h1>{{ $page.Title | markdownify | emojify }}</h1>{{ end }}
74+
75+
<div class="article-style">
76+
{{ $person_page.Content }}
77+
</div>
78+
79+
<div class="row">
80+
81+
{{ with $person.interests }}
82+
<div class="col-md-5">
83+
<div class="section-subheading">{{ i18n "interests" | markdownify }}</div>
84+
<ul class="ul-interests mb-0">
85+
{{ range . }}
86+
<li>{{ . | markdownify | emojify }}</li>
87+
{{ end }}
88+
</ul>
89+
</div>
90+
{{ end }}
91+
92+
{{ with $person.education }}
93+
<div class="col-md-7">
94+
<div class="section-subheading">{{ i18n "education" | markdownify }}</div>
95+
<ul class="ul-edu fa-ul mb-0">
96+
{{ range .courses }}
97+
<li>
98+
<i class="fa-li fas fa-graduation-cap"></i>
99+
<div class="description">
100+
<p class="course">{{ .course }}{{ with .year }}, {{ . }}{{ end }}</p>
101+
<p class="institution">{{ .institution }}</p>
102+
</div>
103+
</li>
104+
{{ end }}
105+
</ul>
106+
</div>
107+
{{ end }}
108+
109+
</div>
110+
</div>
111+
</div>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{{/* People Widget */}}
2+
3+
{{/* Initialise */}}
4+
{{ $ := .root }}
5+
{{ $page := .page }}
6+
{{ $show_social := $page.Params.design.show_social | default false }}
7+
{{ $show_interests := $page.Params.design.show_interests | default true }}
8+
{{ $show_organizations := $page.Params.design.show_organizations | default false }}
9+
{{ $show_role := $page.Params.design.show_role | default true }}
10+
11+
<div class="row justify-content-center people-widget">
12+
{{ with $page.Title }}
13+
<div class="col-md-12 section-heading">
14+
<h1>{{ . | markdownify | emojify }}</h1>
15+
{{ if $page.Params.subtitle }}<p>{{ $page.Params.subtitle | markdownify | emojify }}</p>{{ end }}
16+
</div>
17+
{{ end }}
18+
19+
{{ with $page.Content }}
20+
<div class="col-md-12">
21+
{{ . }}
22+
</div>
23+
{{ end }}
24+
25+
{{ range $page.Params.content.user_groups }}
26+
{{ $query := where (where site.Pages "Section" "authors") ".Params.user_groups" "intersect" (slice .) }}
27+
28+
{{if $query | and (gt (len $page.Params.content.user_groups) 1) }}
29+
<div class="col-md-12">
30+
<h2 class="mb-4">{{ . | markdownify }}</h2>
31+
</div>
32+
{{end}}
33+
34+
{{ range $query }}
35+
{{ $avatar := (.Resources.ByType "image").GetMatch "*avatar*" }}
36+
{{/* Get link to user's profile page. */}}
37+
{{ $link := "" }}
38+
{{ with site.GetPage (printf "/authors/%s" (path.Base (path.Split .Path).Dir)) }}
39+
{{ $link = .RelPermalink }}
40+
{{ end }}
41+
<div class="col-12 col-sm-auto people-person">
42+
{{ $src := "" }}
43+
{{ if site.Params.avatar.gravatar }}
44+
{{ $src = printf "https://s.gravatar.com/avatar/%s?s=150" (md5 .Params.email) }}
45+
{{ else if $avatar }}
46+
{{ $avatar_image := $avatar.Fill "270x270 Center" }}
47+
{{ $src = $avatar_image.RelPermalink }}
48+
{{ end }}
49+
{{ if $src }}
50+
{{ $avatar_shape := site.Params.avatar.shape | default "circle" }}
51+
{{with $link}}<a href="{{.}}">{{end}}<img class="avatar {{if eq $avatar_shape "square"}}avatar-square{{else}}avatar-circle{{end}}" src="{{ $src }}" alt="Avatar">{{if $link}}</a>{{end}}
52+
{{ end }}
53+
54+
<div class="portrait-title">
55+
<h2>{{with $link}}<a href="{{.}}">{{end}}{{ .Title }}{{ with .Params.native_name }}<br>({{ . }}){{ end }}{{if $link}}</a>{{end}}</h2>
56+
{{ if and $show_organizations .Params.organizations }}{{ range .Params.organizations }}<h3>{{ .name }}</h3>{{ end }}{{ end }}
57+
{{ if and $show_role .Params.role }}<h3>{{ .Params.role | markdownify | emojify }}</h3>{{ end }}
58+
{{ if $show_social }}{{ partial "social_links" . }}{{ end }}
59+
{{ if and $show_interests .Params.interests }}<p class="people-interests">{{ delimit .Params.interests ", " | markdownify | emojify }}</p>{{ end }}
60+
</div>
61+
</div>
62+
{{ end }}
63+
{{ end }}
64+
</div>

0 commit comments

Comments
 (0)