add embed info to blog posts?

This commit is contained in:
zyl 2023-11-12 20:55:19 -08:00
parent 1ef077d6dd
commit 5c93449e58
No known key found for this signature in database
GPG key ID: 8611B896D1AAFAF2
4 changed files with 60 additions and 8 deletions

View file

@ -72,6 +72,10 @@ where
fn get_short_desc(&self) -> String;
fn get_extra_resource_template_data(&self, site_config: &SiteConfig) -> anyhow::Result<E>;
fn get_head_data(&self, _site_config: &SiteConfig) -> anyhow::Result<String> {
Ok(String::new())
}
}
#[derive(Debug, Serialize)]
@ -84,6 +88,11 @@ struct ResourceListTemplateData<'r, M, E> {
next: Option<usize>,
}
#[derive(Debug, Serialize)]
struct ExtraResourceRenderData {
head: String,
}
/// Config for the resource builder.
#[derive(Debug)]
pub struct ResourceBuilderConfig {
@ -215,12 +224,15 @@ where
builder.reg.render(&self.config.resource_template, &data)?
};
let out = builder.build_page_raw(
let out = builder.build_page_raw_extra(
PageMetadata {
title: Some(resource.title.clone()),
..Default::default()
},
&out,
ExtraResourceRenderData {
head: resource.get_head_data(&builder.site.config)?,
},
)?;
std::fs::write(out_path, out)?;