diff --git a/src/routes/portfolio.rs b/src/routes/portfolio.rs index ce17d3a..77cc21d 100644 --- a/src/routes/portfolio.rs +++ b/src/routes/portfolio.rs @@ -25,6 +25,8 @@ struct PortfolioTemplate<'a> { navbar: NavBar, location_apps: Option<&'a str>, apps: Option>, + archived_apps: Option>, + archived_apps_exists: bool, err_msg: &'a str, } @@ -39,12 +41,24 @@ fn build_page(config: Config, url: String) -> String { .map(|e| read_file(&e.unwrap().to_string_lossy()).unwrap()) .collect::>(); - let bots_app = if apps.is_empty() { + let appdata = if apps.is_empty() { (None, Some(projects_dir)) } else { (Some(apps), None) }; + // Get archived apps + let archived_apps = glob(&format!("{projects_dir}/archive/*{ext}")) + .unwrap() + .map(|e| read_file(&e.unwrap().to_string_lossy()).unwrap()) + .collect::>(); + + let archived_appdata = if archived_apps.is_empty() { + (None, false) + } else { + (Some(archived_apps), true) + }; + config.tmpl.render( "portfolio.html", PortfolioTemplate { @@ -52,8 +66,10 @@ fn build_page(config: Config, url: String) -> String { portfolio: true, ..NavBar::default() }, - apps: bots_app.0, - location_apps: bots_app.1, + apps: appdata.0, + location_apps: appdata.1, + archived_apps: archived_appdata.0, + archived_apps_exists: archived_appdata.1, err_msg: "is empty", }, Infos { diff --git a/templates/portfolio.html b/templates/portfolio.html index 108864c..777eb8d 100644 --- a/templates/portfolio.html +++ b/templates/portfolio.html @@ -34,7 +34,22 @@ {{/info}} {{/metadata}} {{/apps}} - {{/location_apps}} {{/data}} + + {{#archived_apps_exists}} +

Archives

+
    + {{#archived_apps}} {{#metadata}} {{#info}} +
  • +
    +

    {{title}}

    + {{&content}} {{#language}} +

    + {{/language}} +
    +
  • + {{/info}} {{/metadata}} {{/archived_apps}} +
+ {{/archived_apps_exists}} {{/location_apps}} {{/data}}