Fix category and topic building
This commit is contained in:
parent
276a77b67e
commit
606537d959
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue