parent
ced67bec8b
commit
be88c3c1bc
@ -132,12 +132,15 @@ def generate_parent_navs(path):
|
||||
md = init_md()
|
||||
|
||||
# read the resource
|
||||
with app.open_instance_resource(path, 'r') as entry_file:
|
||||
entry = entry_file.read()
|
||||
_ = Markup(md.convert(entry))
|
||||
page_name = (" ".join(md.Meta.get('title')) if md.Meta.get('title')
|
||||
else request_path_to_breadcrumb_display(request_path))
|
||||
return generate_parent_navs(parent_resource_path) + [(page_name, request_path)]
|
||||
try:
|
||||
with app.open_instance_resource(path, 'r') as entry_file:
|
||||
entry = entry_file.read()
|
||||
_ = Markup(md.convert(entry))
|
||||
page_name = (" ".join(md.Meta.get('title')) if md.Meta.get('title')
|
||||
else request_path_to_breadcrumb_display(request_path))
|
||||
return generate_parent_navs(parent_resource_path) + [(page_name, request_path)]
|
||||
except FileNotFoundError:
|
||||
return generate_parent_navs(parent_resource_path) + [(request_path, request_path)]
|
||||
|
||||
|
||||
def request_path_to_breadcrumb_display(path):
|
||||
|
1
tests/instance/pages/no-index-dir/page.md
Normal file
1
tests/instance/pages/no-index-dir/page.md
Normal file
@ -0,0 +1 @@
|
||||
this is a test page
|
@ -35,6 +35,16 @@ def test_generate_page_navs_subdir_with_title_parsing_real_page(app):
|
||||
]
|
||||
|
||||
|
||||
def test_generate_page_navs_subdir_with_no_index(app):
|
||||
"""Test that breadcrumbs still generate even if a subdir doesn't have an index.md."""
|
||||
with app.app_context():
|
||||
assert generate_parent_navs('pages/no-index-dir/page.md') == [
|
||||
('incorporeal.org', '/'),
|
||||
('/no-index-dir/', '/no-index-dir/'),
|
||||
('page', '/no-index-dir/page')
|
||||
]
|
||||
|
||||
|
||||
def test_render_with_user_dark_theme(app):
|
||||
"""Test that a request with the dark theme selected renders the dark theme."""
|
||||
cookie = dump_cookie("user-style", 'dark')
|
||||
|
Loading…
x
Reference in New Issue
Block a user