Refactored content and sidebar generation into sidebar function