Page abstraction
All checks were successful
CI / Check typos (push) Successful in 10s
CI / Check links (push) Successful in 34s
CI / Clippy (push) Successful in 41s
CI / Build and test (push) Successful in 2m4s
CI / Build container (push) Successful in 3m15s

This commit is contained in:
2025-11-04 08:55:14 -08:00
parent acc057e4cb
commit 4504a88f4b
20 changed files with 522 additions and 233 deletions

View File

@@ -1,26 +1,62 @@
use assetserver::Asset;
use axum::Router;
use axum::routing::get;
use maud::{DOCTYPE, PreEscaped, html};
use tracing::info;
use utoipa::OpenApi;
use crate::{components::misc::FarLink, page::PageServer, pages, routes::assets::Styles_Main};
pub mod assets;
mod betalupi;
mod handouts;
mod index;
mod links;
#[derive(OpenApi)]
#[openapi(tags(), paths(), components(schemas()))]
pub(super) struct Api;
pub(super) fn router() -> Router<()> {
let (asset_prefix, asset_router) = assets::asset_router();
info!("Serving assets at {asset_prefix}");
Router::new()
.route("/", get(index::index))
.route("/whats-a-betalupi", get(betalupi::betalupi))
.route("/links", get(links::links))
.route("/handouts", get(handouts::handouts))
.nest(asset_prefix, asset_router)
let server = PageServer::new(Box::new(|page| {
html! {
(DOCTYPE)
html {
head {
meta charset="UTF" {}
meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" {}
meta content="text/html; charset=UTF-8" http-equiv="content-type" {}
meta property="og:type" content="website" {}
link rel="stylesheet" href=(Styles_Main::URL) {}
(&page.meta)
title { (PreEscaped(page.meta.title.clone())) }
}
body {
div class="wrapper" {
main { ( page.generate_html() ) }
footer {
hr class = "footline" {}
div class = "footContainer" {
p {
"This site was built by hand using "
(FarLink("https://rust-lang.org", "Rust"))
", "
(FarLink("https://maud.lambda.xyz", "Maud"))
", "
(FarLink("https://github.com/connorskees/grass", "Grass"))
", and "
(FarLink("https://docs.rs/axum/latest/axum", "Axum"))
"."
}
}
}
}
}
}
}
}))
.add_page("/", pages::index::page())
.add_page("/links", pages::links::page())
.add_page("/whats-a-betalupi", pages::betalupi::page())
.add_page("/handouts", pages::handouts::page())
.into_router();
Router::new().merge(server).nest(asset_prefix, asset_router)
}