Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

author urls in style name/id #1179

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bin/create_hugo_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ def create_people(srcdir, clean=False):
data = yaml.load(f, Loader=Loader)
# Create a page stub for each person
for name, entry in data.items():
person_dir = "{}/content/people/{}".format(srcdir, name[0])
person_dir = "{}/content/people/{}/{}".format(
srcdir, entry["slug"][0], entry["slug"]
)
if not os.path.exists(person_dir):
os.makedirs(person_dir)
yaml_data = {"name": name, "title": entry["full"], "lastname": entry["last"]}
Expand Down
3 changes: 2 additions & 1 deletion bin/create_hugo_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

from docopt import docopt
from collections import defaultdict
from slugify import slugify
from tqdm import tqdm
import logging as log
import os
Expand Down Expand Up @@ -90,7 +91,7 @@ def export_anthology(anthology, outdir, clean=False, dryrun=False):
name = anthology.people.get_canonical_name(id_)
log.debug("export_anthology: processing person '{}'".format(repr(name)))
data = name.as_dict()
data["slug"] = id_
data["slug"] = slugify(repr(name)) or "NONE"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a PersonName.slug() function in bin/anthology/people.py, I think all slug generation should be done in that class rather than here in the build script.

if id_ in anthology.people.comments:
data["comment"] = anthology.people.comments[id_]
if id_ in anthology.people.similar:
Expand Down
2 changes: 2 additions & 0 deletions data/yaml/name_variants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7531,6 +7531,8 @@
- canonical: {first: Bruce, last: Porter}
variants:
- {first: Bruce W., last: Porter}
- canonical: {first: Matt, last: Post}
id: 0000-0002-1297-6794
- canonical: {first: Oana, last: Postolache}
variants:
- {first: Oana-Diana, last: Postolache}
Expand Down
7 changes: 4 additions & 3 deletions hugo/layouts/partials/author_link.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
- 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
*/}}
{{ $first_letter := slicestr .person.id 0 1 }}
{{ $entry := index .ctx.Site.Data.people $first_letter .person.id }}
{{ $link_to := printf "/people/%s/%s.md" $first_letter .person.id }}
{{ $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>