Fix read_metadata to not return a title if none is defined in index.md.
This fixes the test breakage from adding an index.md with only an Order key defined. Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
This commit is contained in:
@@ -90,7 +90,10 @@ def read_markdown(filename):
|
||||
pass
|
||||
else:
|
||||
output['meta'] = meta
|
||||
output['title'] = md.Meta.get('title', [''])[0]
|
||||
try:
|
||||
output['title'] = md.Meta['title'][0]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
return output
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ def test_read_markdown_empty_file(tmpdir):
|
||||
src = tmpdir.join("file.txt")
|
||||
src.write("content")
|
||||
m = utils.read_markdown(str(src))
|
||||
assert m['title'] == ''
|
||||
assert 'title' not in m
|
||||
assert m['meta'] == {}
|
||||
assert m['description'] == '<p>content</p>'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user