Skip to content

Commit

Permalink
Creation + rebuild refactor
Browse files Browse the repository at this point in the history
- Create series even without posts
- More efficient rebuild tracking
  • Loading branch information
treeman committed Apr 26, 2024
1 parent 778561e commit b83cd90
Show file tree
Hide file tree
Showing 12 changed files with 325 additions and 168 deletions.
6 changes: 3 additions & 3 deletions projects.markdown → projects.dj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: Projects
---toml
title = "Projects"
---

This is a somewhat curated list of my projects. You can find more on [Github][], although I've used it as a dumping ground for random stuff.

[Github]: https://github.com/treeman "My Github profile"
[Github]: https://github.com/treeman

32 changes: 20 additions & 12 deletions src/content/homepage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use serde::Serialize;
use tera::Context;

use crate::content::posts::{PostItem, PostRef};
use crate::content::projects::{GameRef, Project, ProjectContext, ProjectRef};
use crate::content::{Game, GameContext};
use crate::content::{Project, ProjectContext};
use crate::content::{SeriesContext, SeriesItem, SeriesRef};
use crate::paths::AbsPath;
use crate::{item::RenderContext, item::TeraItem, site_url::SiteUrl};
Expand All @@ -19,16 +19,16 @@ pub struct HomepageItem {
pub recent: Vec<PostRef>,
pub recommended: Vec<PostRef>,
pub series: Vec<SeriesRef>,
pub projects: Vec<Project>,
pub games: Vec<Game>,
pub projects: Vec<ProjectRef>,
pub games: Vec<GameRef>,
}

impl HomepageItem {
pub fn new(
posts: &BTreeMap<PostRef, PostItem>,
series: &BTreeMap<SeriesRef, SeriesItem>,
projects: &[Project],
games: &[Game],
projects: &BTreeMap<ProjectRef, Project>,
games: &BTreeMap<GameRef, Game>,
) -> Result<Self> {
let url = SiteUrl::parse("/").expect("Should be able to create a url");

Expand All @@ -38,7 +38,7 @@ impl HomepageItem {
recommended: Self::filter_recommended(posts),
series: Self::filter_series(series),
projects: Self::filter_projects(projects),
games: games.iter().map(Clone::clone).collect(),
games: games.keys().map(Clone::clone).collect(),
})
}

Expand Down Expand Up @@ -72,11 +72,11 @@ impl HomepageItem {
.collect()
}

fn filter_projects(projects: &[Project]) -> Vec<Project> {
fn filter_projects(projects: &BTreeMap<ProjectRef, Project>) -> Vec<ProjectRef> {
projects
.iter()
.filter(|project| project.homepage)
.map(Clone::clone)
.filter(|(_, project)| project.homepage)
.map(|(project_ref, _)| project_ref.clone())
.collect()
}
}
Expand All @@ -98,10 +98,18 @@ impl TeraItem for HomepageItem {
series: self
.series
.iter()
.map(|series| SeriesContext::from_ref(series, ctx))
.map(|x| SeriesContext::from_ref(x, ctx))
.collect(),
projects: self
.projects
.iter()
.map(|x| ProjectContext::from_ref(x, ctx))
.collect(),
games: self
.games
.iter()
.map(|x| GameContext::from_ref(x, ctx))
.collect(),
projects: self.projects.iter().map(|x| x.context(ctx)).collect(),
games: self.games.iter().map(GameContext::from).collect(),
})
.unwrap()
}
Expand Down
2 changes: 1 addition & 1 deletion src/content/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub use external::{JsItem, SassItem};
pub use homepage::HomepageItem;
pub use nav_highlight::add_nav_highlight;
pub use posts::{load_posts, set_post_prev_next, PostItem, PostRef};
pub use projects::{Game, GameContext, Project, ProjectContext, ProjectsItem};
pub use projects::{Game, GameContext, ProjectsItem};
pub use series::{load_series, SeriesContext, SeriesItem, SeriesRef};
pub use series_archive::SeriesArchiveItem;
pub use standalone::{load_standalones, StandaloneItem};
Expand Down
2 changes: 1 addition & 1 deletion src/content/posts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl TeraItem for PostItem {
self,
ctx.content
.get_series(series)
.expect("Could not find series {:?series}"),
.expect(&format!("Could not find series {series:?}")),
ctx,
)
});
Expand Down
Loading

0 comments on commit b83cd90

Please sign in to comment.