diff --git a/site/templates/base.hbs b/site/templates/base.hbs index b701d51..7c12ac4 100644 --- a/site/templates/base.hbs +++ b/site/templates/base.hbs @@ -7,6 +7,9 @@ {{title}} {{{head}}} + {{#each scripts}} + + {{/each}} diff --git a/src/builder.rs b/src/builder.rs index 1a024b1..c5888fb 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -21,6 +21,8 @@ struct TemplateData<'a, T> { pub page: &'a str, /// The page's title. pub title: &'a str, + /// The page's custom scripts. + pub scripts: &'a [String], /// Custom template data. #[serde(flatten)] pub extra_data: T, @@ -213,6 +215,7 @@ impl<'a> SiteBuilder<'a> { &TemplateData { page: page_html, title: &title, + scripts: &page_metadata.scripts, extra_data, }, )?; diff --git a/src/lib.rs b/src/lib.rs index 42714b8..9f24fe1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,6 +67,9 @@ pub struct PageMetadata { pub title: Option, /// The template to use for the page. If not specified, it defaults to "base". pub template: Option, + /// The page's custom scripts, if any. + #[serde(default)] + pub scripts: Vec, /// The extra stuff to run for the page, if any. pub extra: Option, }