Skip to content
Open
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
8 changes: 7 additions & 1 deletion bin/create_hugo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from docopt import docopt
from collections import Counter
from functools import cache
from itertools import chain
import logging as log
import msgspec
from omegaconf import OmegaConf
Expand Down Expand Up @@ -352,7 +353,12 @@ def export_people(anthology, builddir, dryrun):
for person_id, person in anthology.people.items():
cname = person.canonical_name
papers = sorted(
person.papers(),
# papers (which includes frontmatter of volumes)
# + volumes with no frontmatter
chain(
person.papers(),
filter(lambda vol: vol.frontmatter is None, person.volumes()),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

),
key=lambda paper: paper.year,
reverse=True,
)
Expand Down
14 changes: 12 additions & 2 deletions hugo/layouts/people/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,24 @@ <h2 id="title">
{{ range $person.papers }}
{{/* Generate a heading per year -- assumes that papers are already sorted by year,
which the YAML exporter should take care of */}}
{{ $paper := index (index $.Site.Data.papers (index (split . "-") 0)) . }}
{{ $paper := "" }}
{{ if findRE `\.\d+$` . }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oof, I really dislike this. That also only works for new-style IDs, not old ones, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Giving this more thought, I think adding volumes to a list called "papers" is hacky and probably not the right solution, for exactly these reasons (needing hacky ID checks to differentiate them again later, and also requiring two different kinds of templates to render them).

Idea for a better solution: Add has_frontmatter to what gets exported by volume_to_dict() in create_hugo_data.py and check for this in the Hugo template to conditionally render volumes. Still needs them to have their own list-entry-author template or something similar, though.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah that seems workable:

  • Add all volumes to papers (so really it is a list of items associated with the person)
  • In the template, skip rendering ones where has_frontmatter is true
  • We still need to know whether each item is a paper or volume to know which exported YAML to use for lookup. I agree the ID format check is not a great way to do it. Maybe look up the full ID as a volume first, and if no match, assume it is a paper?
  • We also need to construct the URL (page) differently depending on whether it is a paper or volume.
  • And we need a volumes/list-entry-editor.html template

{{ $paper = index (index $.Site.Data.papers (index (split . "-") 0)) . }}
{{ else }}
{{ $paper = index $.Site.Data.volumes . }}
{{ end }}
{{ if and (not $paper.retracted) (not $paper.removed) }}
{{ if ne $paper.year ($.Scratch.Get "current_year") }}
<h4>{{ $paper.year }}</h4>
{{ $.Scratch.Set "current_year" $paper.year }}
{{ end }}

{{ $page := printf "/papers/%s" . }}
{{ $page := "" }}
{{ if findRE `\.\d+$` . }}
{{ $page = printf "/papers/%s" . }}
{{ else }}
{{ $page = printf "/volumes/%s" . }}
{{ end }}
{{ ($.Site.GetPage $page).Render "list-entry-author" }}
{{ end }}
{{ end }}
Expand Down
Loading