Added multiple pages
This commit is contained in:
parent
769aba26e2
commit
c70a31e986
4 changed files with 21 additions and 2 deletions
|
@ -25,6 +25,7 @@ pub async fn router(with_watchers: bool) -> Result<(Router, Vec<Option<FileWatch
|
||||||
|
|
||||||
let mut result = Router::new()
|
let mut result = Router::new()
|
||||||
.route("/", get(index))
|
.route("/", get(index))
|
||||||
|
.route("/about", get(about))
|
||||||
.nest_service("/static", static_file_service)
|
.nest_service("/static", static_file_service)
|
||||||
.with_state(state.clone());
|
.with_state(state.clone());
|
||||||
|
|
||||||
|
@ -45,3 +46,11 @@ async fn index(State(state): State<AppState>) -> Result<Html<String>> {
|
||||||
.await?,
|
.await?,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
async fn about(State(state): State<AppState>) -> Result<Html<String>> {
|
||||||
|
Ok(Html(
|
||||||
|
state
|
||||||
|
.templates
|
||||||
|
.render("pages/about.html.jinja", context!())
|
||||||
|
.await?,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
|
@ -2,12 +2,15 @@
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
|
<script src="https://unpkg.com/htmx.org@1.9.12" integrity="sha384-ujb1lZYygJmzgSwoxRggbCHcjc0rB2XoQrxeTUQyRjrOnlCoYta87iKBWq3EsdM2" crossorigin="anonymous" defer async></script>
|
||||||
<title>Sup</title>
|
<title>Sup</title>
|
||||||
<link rel="stylesheet" type="text/css" href="/static/style.css" />
|
<link rel="stylesheet" type="text/css" href="/static/style.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="bg-base text-text">
|
<body class="bg-base text-text" hx-boost="true">
|
||||||
Page Template
|
Page Template
|
||||||
|
<a href="/">Index</a>
|
||||||
|
<a href="/about">About</a>
|
||||||
{% block body %}{% endblock %}
|
{% block body %}{% endblock %}
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
7
src/templates/pages/about.html.jinja
Normal file
7
src/templates/pages/about.html.jinja
Normal 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 %}
|
|
@ -2,6 +2,6 @@
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<h1>Index</h1>
|
<h1>Index</h1>
|
||||||
<p class="important">
|
<p class="important">
|
||||||
Welcome to my awesome homepage!
|
Welcome to my awesome index!
|
||||||
</p>
|
</p>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue