mirror of
https://github.com/zyllian/zyllian.github.io.git
synced 2025-01-18 11:47:01 -08:00
allow for injecting css scripts into pages
This commit is contained in:
parent
f9b15aa932
commit
8d9866d048
3 changed files with 9 additions and 0 deletions
|
@ -10,6 +10,9 @@
|
||||||
{{#each scripts}}
|
{{#each scripts}}
|
||||||
<script type="text/javascript" src="{{this}}" defer></script>
|
<script type="text/javascript" src="{{this}}" defer></script>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
{{#each styles}}
|
||||||
|
<link rel="stylesheet" href="/styles/{{this}}">
|
||||||
|
{{/each}}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -23,6 +23,8 @@ struct TemplateData<'a, T> {
|
||||||
pub title: &'a str,
|
pub title: &'a str,
|
||||||
/// The page's custom scripts.
|
/// The page's custom scripts.
|
||||||
pub scripts: &'a [String],
|
pub scripts: &'a [String],
|
||||||
|
/// the page's custom styles.
|
||||||
|
pub styles: &'a [String],
|
||||||
/// Custom template data.
|
/// Custom template data.
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub extra_data: T,
|
pub extra_data: T,
|
||||||
|
@ -216,6 +218,7 @@ impl<'a> SiteBuilder<'a> {
|
||||||
page: page_html,
|
page: page_html,
|
||||||
title: &title,
|
title: &title,
|
||||||
scripts: &page_metadata.scripts,
|
scripts: &page_metadata.scripts,
|
||||||
|
styles: &page_metadata.styles,
|
||||||
extra_data,
|
extra_data,
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
|
@ -70,6 +70,9 @@ pub struct PageMetadata {
|
||||||
/// The page's custom scripts, if any.
|
/// The page's custom scripts, if any.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub scripts: Vec<String>,
|
pub scripts: Vec<String>,
|
||||||
|
/// the page's custom styles, if any.
|
||||||
|
#[serde(default)]
|
||||||
|
pub styles: 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
Reference in a new issue