portfolio genericity
This commit is contained in:
parent
bc14e1b393
commit
c787171d6b
2 changed files with 14 additions and 9 deletions
|
@ -20,6 +20,7 @@ async fn page(config: web::Data<Config>) -> impl Responder {
|
|||
#[derive(Content, Debug)]
|
||||
struct PortfolioTemplate<'a> {
|
||||
navbar: NavBar,
|
||||
about: Option<File>,
|
||||
location_apps: Option<&'a str>,
|
||||
apps: Option<Vec<File>>,
|
||||
archived_apps: Option<Vec<File>>,
|
||||
|
@ -30,22 +31,29 @@ struct PortfolioTemplate<'a> {
|
|||
#[once(time = 60)]
|
||||
fn build_page(config: Config) -> String {
|
||||
let projects_dir = format!("{}/projects", config.locations.data_dir);
|
||||
let apps_dir = format!("{}/apps", projects_dir);
|
||||
let ext = ".md";
|
||||
|
||||
// Get about
|
||||
let about = read_file(
|
||||
&format!("{}/about.md", projects_dir),
|
||||
TypeFileMetadata::Generic,
|
||||
);
|
||||
|
||||
// Get apps
|
||||
let apps = glob(&format!("{projects_dir}/*{ext}"))
|
||||
let apps = glob(&format!("{apps_dir}/*{ext}"))
|
||||
.unwrap()
|
||||
.map(|e| read_file(&e.unwrap().to_string_lossy(), TypeFileMetadata::Portfolio).unwrap())
|
||||
.collect::<Vec<File>>();
|
||||
|
||||
let appdata = if apps.is_empty() {
|
||||
(None, Some(projects_dir.as_str()))
|
||||
(None, Some(apps_dir.as_str()))
|
||||
} else {
|
||||
(Some(apps), None)
|
||||
};
|
||||
|
||||
// Get archived apps
|
||||
let archived_apps = glob(&format!("{projects_dir}/archive/*{ext}"))
|
||||
let archived_apps = glob(&format!("{apps_dir}/archive/*{ext}"))
|
||||
.unwrap()
|
||||
.map(|e| read_file(&e.unwrap().to_string_lossy(), TypeFileMetadata::Portfolio).unwrap())
|
||||
.collect::<Vec<File>>();
|
||||
|
@ -63,6 +71,7 @@ fn build_page(config: Config) -> String {
|
|||
portfolio: true,
|
||||
..NavBar::default()
|
||||
},
|
||||
about,
|
||||
apps: appdata.0,
|
||||
location_apps: appdata.1,
|
||||
archived_apps: archived_appdata.0,
|
||||
|
|
|
@ -10,14 +10,10 @@
|
|||
<main>
|
||||
{{#data}}
|
||||
<h1>Portfolio</h1>
|
||||
<p>
|
||||
Je programme depuis 2018 et j'ai appris une multitude de langages
|
||||
depuis. Étant passionné de logiciels libres depuis que je m'y intéresse,
|
||||
je publie tout sur des forges publiques.
|
||||
</p>
|
||||
{{#about}} {{&content}} {{/about}}
|
||||
|
||||
{{#location_apps}}
|
||||
<!-- Error message -->
|
||||
{{#location_apps}}
|
||||
<p>{{location_apps}} {{err_msg}}</p>
|
||||
{{/location_apps}} {{^location_apps}}
|
||||
|
||||
|
|
Loading…
Reference in a new issue