Post date & tags
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Blender 2020
|
||||
description: 2020 blender artworks
|
||||
tags: 2020 blender artworks
|
||||
date: 2020-01-01
|
||||
yearonly: true
|
||||
url: 2020.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Blender 2021
|
||||
description: 2021 blender artworks
|
||||
tags: 2021 blender artworks
|
||||
date: 2021-01-01
|
||||
yearonly: true
|
||||
url: 2021.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Les sites web perso
|
||||
description: blog sites perso
|
||||
tags: blog sites perso
|
||||
date: 2020-01-04
|
||||
yearonly: false
|
||||
url: les-sites-web-perso.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: La grande virtualization
|
||||
description: docker virtualization
|
||||
tags: docker virtualization
|
||||
date: 2020-01-12
|
||||
yearonly: false
|
||||
url: la-grande-virtualization.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Migration gitea vers docker
|
||||
description: gitea docker
|
||||
tags: gitea docker
|
||||
date: 2020-03-03
|
||||
yearonly: false
|
||||
url: migration-gitea-docker.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
---
|
||||
title: Faire une PWA avec VueJS
|
||||
description: docker vuejs buefy
|
||||
tags: docker vuejs buefy
|
||||
date: 2020-03-07
|
||||
yearonly: false
|
||||
url: pwavuejs.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Sculpter avec Blender
|
||||
description: sculpt blender 3D
|
||||
tags: sculpt blender 3D
|
||||
date: 2020-04-19
|
||||
yearonly: false
|
||||
url: sculptblender.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Les frameworks Javascript
|
||||
description: javascript framework
|
||||
tags: javascript framework
|
||||
date: 2020-04-23
|
||||
yearonly: false
|
||||
url: vanillajs.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Sculpter avec Blender 2
|
||||
description: sculpt blender 3D
|
||||
tags: sculpt blender 3D
|
||||
date: 2020-06-06
|
||||
yearonly: false
|
||||
url: sculptblender2.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Setup Gitea / Drone / Docker
|
||||
description: gitea drone cicd docker
|
||||
tags: gitea drone cicd docker
|
||||
date: 2021-01-15
|
||||
yearonly: false
|
||||
url: giteadronedocker.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Initial2D
|
||||
description: A simple GTK race game
|
||||
tags: A simple GTK race game
|
||||
date: 2018-01-01
|
||||
yearonly: true
|
||||
url: initial2D.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Oozik
|
||||
description: Lecteur de musique collaboratif
|
||||
tags: Lecteur de musique collaboratif
|
||||
date: 2019-01-01
|
||||
yearonly: true
|
||||
url: oozik.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: NexusV6
|
||||
description: Main website, iteration 6
|
||||
tags: Main website, iteration 6
|
||||
date: 2019-02-01
|
||||
yearonly: true
|
||||
url: nexusv6.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Etienne's Remote
|
||||
description: Une télécommande de soundboard
|
||||
tags: Une télécommande de soundboard
|
||||
date: 2020-01-01
|
||||
yearonly: true
|
||||
url: etienneremote.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cloud32
|
||||
description: Un cloud personnel pas pratique
|
||||
tags: Un cloud personnel pas pratique
|
||||
date: 2020-02-01
|
||||
yearonly: true
|
||||
url: cloud32.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: LilStreamy
|
||||
description: application web video p2p
|
||||
tags: application web video p2p
|
||||
date: 2020-03-01
|
||||
yearonly: true
|
||||
url: lilstreamy.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Mozen
|
||||
description: Bibliothèque de machine learning
|
||||
tags: Bibliothèque de machine learning
|
||||
date: 2020-04-01
|
||||
yearonly: true
|
||||
url: mozen.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Voozik
|
||||
description: Application web musique/video p2p
|
||||
tags: Application web musique/video p2p
|
||||
date: 2020-05-01
|
||||
yearonly: true
|
||||
url: voozik.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Tron.io
|
||||
description: Jeu web
|
||||
tags: Jeu web
|
||||
date: 2020-06-01
|
||||
yearonly: true
|
||||
url: tronio.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: NexusV7
|
||||
description: Static site generator
|
||||
tags: Static site generator
|
||||
tags: rust, static site generator
|
||||
date: 2021-01-01
|
||||
yearonly: true
|
||||
|
||||
@@ -54,6 +54,8 @@ fn load_section(dir_entry: &DirEntry) -> Section {
|
||||
let section_name = dir_entry.file_name().into_string().unwrap();
|
||||
let section_url = section_name.to_lowercase().trim().replace(" ", "_");
|
||||
|
||||
section_posts.sort_by(|a, b| b.date_compare.partial_cmp(&a.date_compare).unwrap());
|
||||
|
||||
println!("[LOADER] Loaded section {} with {} posts", section_name, section_posts.len());
|
||||
|
||||
return Section {
|
||||
@@ -70,4 +72,4 @@ fn load_post(path: &Path) -> Post {
|
||||
};
|
||||
let marky = Marky::from_file(&file);
|
||||
return Post::from_marky(marky);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,9 @@ use crate::markdown::marky::Marky;
|
||||
pub struct Post {
|
||||
pub title: String,
|
||||
pub date: String,
|
||||
pub date_compare: i32,
|
||||
pub date_printable: String,
|
||||
pub url: String,
|
||||
pub description: String,
|
||||
pub tags: Vec<String>,
|
||||
pub body: String,
|
||||
pub is_year_only: bool,
|
||||
@@ -17,11 +18,30 @@ pub struct Post {
|
||||
|
||||
impl Post {
|
||||
pub fn from_marky(marky: Marky) -> Post {
|
||||
let date = marky.metadata.get("date").map_or(String::from("none"), String::from);
|
||||
let is_year_only = marky.metadata.get("yearonly").map_or(false, |a| a == "true");
|
||||
|
||||
let (year, month, day) = to_date_number(&date);
|
||||
|
||||
let date_compare = year * 1200 + month * 100 + day;
|
||||
|
||||
let mut date_printable = String::new();
|
||||
if is_year_only {
|
||||
date_printable.push_str(&year.to_string());
|
||||
} else {
|
||||
date_printable.push_str(&day.to_string());
|
||||
date_printable.push_str("-");
|
||||
date_printable.push_str(&month.to_string());
|
||||
date_printable.push_str("-");
|
||||
date_printable.push_str(&year.to_string());
|
||||
}
|
||||
|
||||
Post {
|
||||
title: marky.metadata.get("title").map_or(String::from("none"), String::from),
|
||||
date: marky.metadata.get("date").map_or(String::from("none"), String::from),
|
||||
date: date,
|
||||
date_compare: date_compare,
|
||||
date_printable: date_printable,
|
||||
url: marky.metadata.get("url").map_or(String::from("none"), String::from),
|
||||
description: marky.metadata.get("description").map_or(String::from("none"), String::from),
|
||||
tags: tags_string_to_vec(marky.metadata.get("tags").map_or(String::from("none"), String::from)),
|
||||
is_year_only: marky.metadata.get("yearonly").map_or(false, |a| a == "true"),
|
||||
body: to_html(&marky.content),
|
||||
@@ -30,5 +50,20 @@ impl Post {
|
||||
}
|
||||
|
||||
fn tags_string_to_vec(tags: String) -> Vec<String> {
|
||||
return tags.split(",").map(String::from).collect();
|
||||
return tags.split_whitespace().map(String::from).collect();
|
||||
}
|
||||
|
||||
// Convert yyyy-MM-dd to yyyy, MM, dd
|
||||
fn to_date_number(date: &String) -> (i32, i32, i32) {
|
||||
let split: Vec<&str> = date.split("-").collect();
|
||||
|
||||
if split.len() == 0 {
|
||||
return (0, 0, 0);
|
||||
}
|
||||
|
||||
let year = split[0].parse::<i32>().unwrap();
|
||||
let month = split[1].parse::<i32>().unwrap();
|
||||
let day = split[2].parse::<i32>().unwrap();
|
||||
|
||||
return (year, month, day);
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
<div class="contentContainer">
|
||||
<article>
|
||||
<h1>{{post.title}}</h1>
|
||||
<h5>{{post.date}}</h5>
|
||||
<h5>
|
||||
{{#each post.tags}}
|
||||
<span>{{this}}</span>
|
||||
{{/each}}
|
||||
</h5>
|
||||
<h5>{{post.date_printable}}</h5>
|
||||
<hr/>
|
||||
{{{post.body}}}
|
||||
<hr/>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{{#each section.posts}}
|
||||
<a href="{{this.url}}">
|
||||
<span class="postTitle">{{this.title}}</span>
|
||||
<span class="postDate">{{this.date}}</span>
|
||||
<span class="postDate">{{this.date_printable}}</span>
|
||||
</a>
|
||||
{{/each}}
|
||||
</nav>
|
||||
|
||||
Reference in New Issue
Block a user