mirror of
https://github.com/zyllian/zyllian.github.io.git
synced 2025-05-09 18:16:43 -07:00
implement custom embeds for regular pages
This commit is contained in:
parent
750c0c501f
commit
4fb1f2183d
5 changed files with 28 additions and 6 deletions
|
@ -21,6 +21,8 @@ struct TemplateData<'a, T> {
|
|||
pub page: &'a str,
|
||||
/// The page's title.
|
||||
pub title: &'a str,
|
||||
/// Custom head data for the page.
|
||||
pub head: Option<String>,
|
||||
/// The page's custom scripts.
|
||||
pub scripts: &'a [String],
|
||||
/// the page's custom styles.
|
||||
|
@ -214,11 +216,17 @@ impl<'a> SiteBuilder<'a> {
|
|||
_ => self.site.config.title.clone(),
|
||||
};
|
||||
|
||||
let head = page_metadata.embed.map(|mut embed| {
|
||||
embed.site_name.clone_from(&self.site.config.title);
|
||||
embed.build()
|
||||
});
|
||||
|
||||
let out = self.reg.render(
|
||||
&page_metadata.template.unwrap_or_else(|| "base".to_string()),
|
||||
&TemplateData {
|
||||
page: page_html,
|
||||
title: &title,
|
||||
head,
|
||||
scripts: &page_metadata.scripts,
|
||||
styles: &page_metadata.styles,
|
||||
extra_data,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue