WIP: Website Initial Implementation #1
					 2 changed files with 17 additions and 4 deletions
				
			
		|  | @ -3,6 +3,7 @@ | ||||||
| from os.path import isfile, join, dirname | from os.path import isfile, join, dirname | ||||||
| from nicegui import ui | from nicegui import ui | ||||||
| 
 | 
 | ||||||
|  | # TODO: Read from configuration | ||||||
| _tab_to_content = { | _tab_to_content = { | ||||||
|     "Home": "page_content/home.md", |     "Home": "page_content/home.md", | ||||||
|     "Portfolio": "page_content/portfolio.md", |     "Portfolio": "page_content/portfolio.md", | ||||||
|  | @ -11,6 +12,8 @@ _tab_to_content = { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| _error_page = "page_content/404.md" | _error_page = "page_content/404.md" | ||||||
|  | _footer_block = "page_content/footer.html" | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| def _get_content_from_file(file_name: str) -> str: | def _get_content_from_file(file_name: str) -> str: | ||||||
|     """ |     """ | ||||||
|  | @ -25,23 +28,30 @@ def _get_content_from_file(file_name: str) -> str: | ||||||
| 
 | 
 | ||||||
| def render_tab(tab_name: str): | def render_tab(tab_name: str): | ||||||
|     file_name = _tab_to_content.get(tab_name, _error_page) |     file_name = _tab_to_content.get(tab_name, _error_page) | ||||||
|     ui.markdown(_get_content_from_file(file_name), extras=['cuddled-lists', 'fenced-code-blocks', 'tables']) |     with ui.scroll_area().classes('w-full h-screen no-wrap'): | ||||||
|  |         ui.markdown(_get_content_from_file(file_name), extras=['cuddled-lists', 'fenced-code-blocks', 'tables']) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def render_header() -> ui.tab_panels: | def render_main() -> ui.tab_panels: | ||||||
|     """ |     """ | ||||||
|     Render sticky page header with navigation |     Render sticky page header with navigation | ||||||
|     """ |     """ | ||||||
|     tab_names = _tab_to_content.keys() |     tab_names = _tab_to_content.keys() | ||||||
|     with ui.tabs().classes('w-full') as tabs: |     with ui.tabs().classes('w-full') as tabs: | ||||||
|         tab_list = {name: ui.tab(name) for name in tab_names} |         tab_list = {name: ui.tab(name) for name in tab_names} | ||||||
|     with ui.tab_panels(tabs).classes('w-full') as header: |     with ui.tab_panels(tabs).classes('w-full h-screen no-wrap') as header: | ||||||
|         for name, t in tab_list.items(): |         for name, t in tab_list.items(): | ||||||
|             with ui.tab_panel(t): |             with ui.tab_panel(t): | ||||||
|                 render_tab(name) |                 render_tab(name) | ||||||
|     return header |     return header | ||||||
| 
 | 
 | ||||||
| def main(): | def main(): | ||||||
|     header = render_header() |     header = render_main() | ||||||
|     header.set_value(list(_tab_to_content.keys())[0]) |     header.set_value(list(_tab_to_content.keys())[0]) | ||||||
|  |     ui.query('.nicegui-content').classes('h-screen no-wrap') | ||||||
|  |     ui.html(_get_content_from_file(_footer_block), tag="footer").classes("rounded-lg shadow-sm m-4 w-full text-center") | ||||||
|     ui.run(dark=None, reload=False, title="Daniel McKnight") |     ui.run(dark=None, reload=False, title="Daniel McKnight") | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | if __name__ == "__main__": | ||||||
|  |     main() | ||||||
							
								
								
									
										3
									
								
								site_mcknight_tech/page_content/footer.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								site_mcknight_tech/page_content/footer.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,3 @@ | ||||||
|  | <span class="text-sm text-gray-500 sm:text-center dark:text-gray-400"> | ||||||
|  |     © 2025 Daniel McKnight. All Rights Reserved. | ||||||
|  | </span> | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue