WIP: new blog layout
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending

This commit is contained in:
Mylloon 2023-04-24 18:01:38 +02:00
parent fd228be916
commit 65de1f1777
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 147 additions and 13 deletions

View file

@ -20,10 +20,11 @@ pub async fn index(config: web::Data<Config>) -> impl Responder {
#[derive(Content)] #[derive(Content)]
struct BlogIndexTemplate { struct BlogIndexTemplate {
posts: Option<Vec<Post>>, posts: Vec<Post>,
no_posts: bool,
} }
#[once(time = 120)] //#[once(time = 120)]
pub fn build_index(config: Config) -> String { pub fn build_index(config: Config) -> String {
let mut posts = get_posts("data/blog"); let mut posts = get_posts("data/blog");
@ -34,7 +35,8 @@ pub fn build_index(config: Config) -> String {
config.tmpl.render( config.tmpl.render(
"blog/index.html", "blog/index.html",
BlogIndexTemplate { BlogIndexTemplate {
posts: if posts.is_empty() { None } else { Some(posts) }, no_posts: posts.is_empty(),
posts,
}, },
Infos { Infos {
page_title: Some("Blog".to_owned()), page_title: Some("Blog".to_owned()),

123
static/css/blog/index.css Normal file
View file

@ -0,0 +1,123 @@
@media (prefers-color-scheme: light) {
/* TODO: Make light different from dark */
:root {
--bg: #171e26;
--line: #374351;
--date: #242e38;
--point: #515f70;
--bg-hover: #071f2a;
--point-hover: #0f0;
--font-color: #fff;
--title-color: #34ace0;
}
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #171e26;
--line: #374351;
--date: #242e38;
--point: #515f70;
--bg-hover: #071f2a;
--point-hover: #0f0;
--font-color: #fff;
--title-color: #34ace0;
}
}
*,
html,
body {
/* padding: 0px; */
margin: 0px;
box-sizing: border-box;
font-family: sans-serif;
/* perspective: 800px; */
}
body {
background-color: var(--bg);
/* width: 100%; */
/* min-height: 100vh; */
display: flex;
justify-content: center;
/* align-items: center; */
}
.timeline {
width: 800px;
color: var(--font-color);
padding: 30px 20px;
}
.timeline ul {
list-style-type: none;
border-left: 2px solid var(--line);
padding: 10px 5px;
}
.timeline ul li {
padding: 20px 20px;
position: relative;
cursor: pointer;
transition: 0.5s;
}
/* Dates */
.timeline ul li span {
display: inline-block;
background-color: var(--date);
border-radius: 25px;
padding: 2px 5px;
font-size: 15px;
/* text-align: center; */
}
/* Titles */
.timeline ul li .content h3 > a {
color: var(--title-color);
font-size: 17px;
padding-top: 5px;
text-decoration: none;
}
/* Descriptions */
.timeline ul li .content p {
padding: 5px 0px 15px 0px;
font-size: 15px;
}
/* Points côté */
.timeline ul li:before {
position: absolute;
content: "";
width: 10px;
height: 10px;
background-color: var(--point);
border-radius: 50%;
left: -11px;
top: 28px;
transition: 0.2s;
}
/* Card hover */
.timeline ul li:hover {
background-color: var(--bg-hover);
}
/* Point côté hover */
.timeline ul li:hover:before {
background-color: var(--point-hover);
box-shadow: 0px 0px 10px 2px var(--point-hover);
}
@media only screen and (max-width: 300px) {
.timeline {
/* width: 100%; */
padding: 30px 5px 30px 10px;
}
.timeline ul li .content h3 > a {
color: var(--title-color);
font-size: 15px;
}
}

View file

@ -1,20 +1,29 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="index" lang="fr"> <html class="index" lang="fr">
<head dir="ltr"> <head dir="ltr">
{{>head.html}} {{>blog/head.html}}
<link rel="stylesheet" href="/css/blog/index.css" />
</head> </head>
<body class="index"> <body class="index">
{{#data}} {{#data}}
<h1 id="title">Blog</h1> <h1 id="title">Blog</h1>
<div id="content"> {{#no_posts}}
{{^posts}} <h2 class="subtitle">Aucun posts</h2>
<h2 class="subtitle">Aucun posts</h2> {{/no_posts}} {{^no_posts}}
{{/posts}} {{#posts}} <div class="timeline">
<h2 class="subtitle"> <ul>
<a href="/blog/{{url}}">{{title}}</a> {{#posts}}
</h2> <li>
{{/posts}} <span>DATE</span>
<div class="content">
<h3><a href="/blog/{{url}}">{{title}}</a></h3>
<p>SHORT DESC</p>
</div>
</li>
{{/posts}}
</ul>
</div> </div>
{{/data}} {{>footer.html}} {{/no_posts}} {{/data}} {{>footer.html}}
</body> </body>
</html> </html>