Persist posts_per_page across pages
This commit is contained in:
parent
918ce056bc
commit
236bc56f03
@ -26,7 +26,7 @@ type Result<T, E = rocket::response::Debug<sqlx::Error>> = std::result::Result<T
|
|||||||
mod post;
|
mod post;
|
||||||
pub use post::Entity as Post;
|
pub use post::Entity as Post;
|
||||||
|
|
||||||
const DEFAULT_POSTS_PER_PAGE: usize = 25;
|
const DEFAULT_POSTS_PER_PAGE: usize = 5;
|
||||||
|
|
||||||
#[get("/new")]
|
#[get("/new")]
|
||||||
fn new() -> Template {
|
fn new() -> Template {
|
||||||
@ -97,6 +97,7 @@ async fn list(
|
|||||||
posts: posts,
|
posts: posts,
|
||||||
flash: flash,
|
flash: flash,
|
||||||
page: page,
|
page: page,
|
||||||
|
posts_per_page: posts_per_page,
|
||||||
num_pages: num_pages,
|
num_pages: num_pages,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -27,9 +27,9 @@
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td>
|
<td>
|
||||||
{% if page == 0 %} Previous {% else %}
|
{% if page == 0 %} Previous {% else %}
|
||||||
<a href="/?page={{ page - 1 }}">Previous</a>
|
<a href="/?page={{ page - 1 }}&posts_per_page={{ posts_per_page }}">Previous</a>
|
||||||
{% endif %} | {% if page == num_pages - 1 %} Next {% else %}
|
{% endif %} | {% if page == num_pages - 1 %} Next {% else %}
|
||||||
<a href="/?page={{ page + 1 }}">Next</a>
|
<a href="/?page={{ page + 1 }}&posts_per_page={{ posts_per_page }}">Next</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user