Skip to content

Commit

Permalink
Fix error on empty blog search results
Browse files Browse the repository at this point in the history
  • Loading branch information
syeopite committed Dec 29, 2024
1 parent 8cd3a8f commit 08c6a6a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/routes/blogs/blogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ async def _blog_search(request: sanic.Request, blog: str, query: str):
if continuation := request.args.get("continuation"):
continuation = urllib.parse.unquote(continuation)

blog = (await get_blog_search_results(request.app.ctx, blog, query, continuation=continuation))
try:
blog = (await get_blog_search_results(request.app.ctx, blog, query, continuation=continuation))
except IndexError:
# When no search results are found blog information will also be missing
blog = await get_blog_posts(request.app.ctx, blog)
blog.posts.clear()

return await sanic_ext.render(
"blog/blog_search.jinja",
Expand Down

0 comments on commit 08c6a6a

Please sign in to comment.