Skip to content

Commit

Permalink
fix(blog): copy author avatars
Browse files Browse the repository at this point in the history
  • Loading branch information
fiji-flo committed Oct 2, 2024
1 parent 28f461f commit ccd5231
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions crates/rari-doc/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ use std::borrow::Cow;
use std::fs::{self, File};
use std::io::BufWriter;
use std::iter::once;
use std::path::PathBuf;

use rari_types::globals::build_out_root;
use rari_types::locale::Locale;
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use tracing::{error, span, Level};

Expand Down Expand Up @@ -70,7 +72,31 @@ pub fn build_curriculum_pages() -> Result<Vec<Cow<'static, str>>, DocError> {
.collect())
}

fn copy_blog_author_avatars() -> Result<(), DocError> {
for (slug, author) in &blog_files().authors {
if let Some(avatar) = &author.frontmatter.avatar {
let out_path = build_out_root()?.join(
[
Locale::default().as_folder_str(),
"blog",
"author",
slug.as_str(),
]
.iter()
.collect::<PathBuf>(),
);

fs::create_dir_all(&out_path)?;
let from = author.path.with_file_name(avatar);
let to = out_path.join(avatar);
fs::copy(from, to)?;
}
}
Ok(())
}

pub fn build_blog_pages() -> Result<Vec<Cow<'static, str>>, DocError> {
copy_blog_author_avatars()?;
Ok(blog_files()
.posts
.values()
Expand Down

0 comments on commit ccd5231

Please sign in to comment.