MainTemplate.vala 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Astralis;
  2. using Spry;
  3. using Inversion;
  4. /**
  5. * MainTemplate - The base template for documentation pages
  6. *
  7. * Provides a clean, minimal HTML structure for documentation:
  8. * - HTML5 document structure
  9. * - NavSidebarComponent for navigation
  10. * - docs.css stylesheet for documentation styling
  11. * - htmx.js and htmx-sse.js for interactive components
  12. * - Template outlet for page content
  13. */
  14. public class MainTemplate : PageTemplate {
  15. private NavSidebarComponent nav;
  16. private RouteContext route_context = inject<RouteContext>();
  17. public override string markup { get {
  18. return """
  19. <!DOCTYPE html>
  20. <html lang="en">
  21. <head>
  22. <meta charset="utf-8">
  23. <meta name="viewport" content="width=device-width, initial-scale=1">
  24. <title>Spry Documentation</title>
  25. <link rel="stylesheet" spry-res="docs.css">
  26. </head>
  27. <body>
  28. <div class="page-container">
  29. <spry-component name="NavSidebarComponent" sid="nav"/>
  30. <main class="main-content">
  31. <spry-template-outlet/>
  32. </main>
  33. </div>
  34. <script spry-res="htmx.js"></script>
  35. <script spry-res="htmx-sse.js"></script>
  36. </body>
  37. </html>
  38. """;
  39. }}
  40. public override async void prepare() throws Error {
  41. // Get the nav component and set the current path from the route context
  42. nav = get_component_child<NavSidebarComponent>("nav");
  43. nav.current_path = route_context.requested_path;
  44. }
  45. }