Fix category and topic building

This commit is contained in:
Tim Van Baak 2021-02-12 10:13:34 -08:00
parent 276a77b67e
commit 606537d959
1 changed files with 6 additions and 4 deletions

View File

@ -17,16 +17,18 @@ def generate_index_document(directory: str) -> Document:
document: Document = load(f)
# Check if this document specifies a tab, and create it if necessary.
category = document.get_tag('category')
if not category:
if category_tag := document.get_tag('category'):
category = category_tag.value
else:
category = 'index'
if category not in categories:
categories[category] = {}
category_tab = categories[category]
# Check if this document specifies a topic, and create it if necessary.
topic = document.get_tag('topic')
if not topic:
if topic_tag := document.get_tag('topic'):
topic = topic_tag.value
else:
topic = 'uncategorized'
if '.' in topic:
topic, subtopic = topic.split('.', maxsplit=1)