Skip to content

Commit

Permalink
author urls in style name/id
Browse files Browse the repository at this point in the history
Issue #623

Now generates author pages with urls in form name/id

for most people this looks like:
 people/d/david-chiang/david-chiang/

Matt Post has an ORCID in name_variants.yaml, so his page is:
 people/m/matt-post/0000-0002-1297-6794/

and then there is:
 people/y/yang-liu/yang-liu-edinburgh/
 people/y/yang-liu/yang-liu-ict/
 people/y/yang-liu/yang-liu-icsi/
 people/y/yang-liu/yang-liu-umich/

I don't know how to make the old URLs people/m/matt-post/ resolve.
  • Loading branch information
Daniel Gildea committed Jan 3, 2021
1 parent 5364373 commit 0459bbf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bin/create_hugo_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ 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 @@ -76,7 +77,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"
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 @@ -7469,6 +7469,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>

0 comments on commit 0459bbf

Please sign in to comment.