mirror of
https://github.com/zyllian/zyllian.github.io.git
synced 2025-05-09 18:16:43 -07:00
add support for custom scripts on a page
This commit is contained in:
parent
4d1d5308d3
commit
831a1486ee
3 changed files with 9 additions and 0 deletions
|
@ -7,6 +7,9 @@
|
||||||
<link rel="stylesheet" href="/styles/index.css">
|
<link rel="stylesheet" href="/styles/index.css">
|
||||||
<title>{{title}}</title>
|
<title>{{title}}</title>
|
||||||
{{{head}}}
|
{{{head}}}
|
||||||
|
{{#each scripts}}
|
||||||
|
<script src="{{this}}"></script>
|
||||||
|
{{/each}}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -21,6 +21,8 @@ struct TemplateData<'a, T> {
|
||||||
pub page: &'a str,
|
pub page: &'a str,
|
||||||
/// The page's title.
|
/// The page's title.
|
||||||
pub title: &'a str,
|
pub title: &'a str,
|
||||||
|
/// The page's custom scripts.
|
||||||
|
pub scripts: &'a [String],
|
||||||
/// Custom template data.
|
/// Custom template data.
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub extra_data: T,
|
pub extra_data: T,
|
||||||
|
@ -213,6 +215,7 @@ impl<'a> SiteBuilder<'a> {
|
||||||
&TemplateData {
|
&TemplateData {
|
||||||
page: page_html,
|
page: page_html,
|
||||||
title: &title,
|
title: &title,
|
||||||
|
scripts: &page_metadata.scripts,
|
||||||
extra_data,
|
extra_data,
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
|
@ -67,6 +67,9 @@ pub struct PageMetadata {
|
||||||
pub title: Option<String>,
|
pub title: Option<String>,
|
||||||
/// The template to use for the page. If not specified, it defaults to "base".
|
/// The template to use for the page. If not specified, it defaults to "base".
|
||||||
pub template: Option<String>,
|
pub template: Option<String>,
|
||||||
|
/// The page's custom scripts, if any.
|
||||||
|
#[serde(default)]
|
||||||
|
pub scripts: Vec<String>,
|
||||||
/// The extra stuff to run for the page, if any.
|
/// The extra stuff to run for the page, if any.
|
||||||
pub extra: Option<String>,
|
pub extra: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue