Skip to content

Commit 1e540e1

Browse files
authored
Merge pull request #408 from VirtualFlyBrain/fix/empty-tags-yaml
Fix invalid YAML front matter for terms with no tags
2 parents e783b33 + af8e68b commit 1e540e1

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

vfbterms.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,11 +497,14 @@ def generate_page(term_data):
497497
url_slug = get_term_url(name, term_id)
498498

499499
# Tags for front matter
500-
tags_csv = ",".join(tags)
500+
# Build a clean list and drop empties, otherwise a term with no Tags
501+
# yields a leading comma (e.g. "[,VFB]") which is invalid YAML flow syntax
502+
tag_list = list(tags)
501503
if "_" in term_id:
502-
tags_csv += "," + term_id.split("_")[0]
504+
tag_list.append(term_id.split("_")[0])
503505
elif term_id.startswith("FB"):
504-
tags_csv += "," + term_id[0:4]
506+
tag_list.append(term_id[0:4])
507+
tags_csv = ",".join(t for t in tag_list if t)
505508

506509
# Thumbnails
507510
thumbnails = get_thumbnails(term_data)

0 commit comments

Comments
 (0)