Added multiple pages

This commit is contained in:
Daniel Flanagan 2024-05-14 16:56:22 -05:00
parent 769aba26e2
commit c70a31e986
4 changed files with 21 additions and 2 deletions

View file

@ -25,6 +25,7 @@ pub async fn router(with_watchers: bool) -> Result<(Router, Vec<Option<FileWatch
let mut result = Router::new()
.route("/", get(index))
.route("/about", get(about))
.nest_service("/static", static_file_service)
.with_state(state.clone());
@ -45,3 +46,11 @@ async fn index(State(state): State<AppState>) -> Result<Html<String>> {
.await?,
))
}
async fn about(State(state): State<AppState>) -> Result<Html<String>> {
Ok(Html(
state
.templates
.render("pages/about.html.jinja", context!())
.await?,
))
}

View file

@ -2,12 +2,15 @@
<html>
<head>
<script src="https://unpkg.com/htmx.org@1.9.12" integrity="sha384-ujb1lZYygJmzgSwoxRggbCHcjc0rB2XoQrxeTUQyRjrOnlCoYta87iKBWq3EsdM2" crossorigin="anonymous" defer async></script>
<title>Sup</title>
<link rel="stylesheet" type="text/css" href="/static/style.css" />
</head>
<body class="bg-base text-text">
<body class="bg-base text-text" hx-boost="true">
Page Template
<a href="/">Index</a>
<a href="/about">About</a>
{% block body %}{% endblock %}
</body>

View file

@ -0,0 +1,7 @@
{% extends "page.html.jinja" %}
{% block body %}
<h1>About</h1>
<p class="important">
Welcome to my awesome about page!
</p>
{% endblock %}

View file

@ -2,6 +2,6 @@
{% block body %}
<h1>Index</h1>
<p class="important">
Welcome to my awesome homepage!
Welcome to my awesome index!
</p>
{% endblock %}