mirror of
https://github.com/zyllian/zyllian.github.io.git
synced 2025-01-18 03:32:30 -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}}
|
||||
<script type="text/javascript" src="{{this}}" defer></script>
|
||||
{{/each}}
|
||||
{{#each styles}}
|
||||
<link rel="stylesheet" href="/styles/{{this}}">
|
||||
{{/each}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
|
|
@ -23,6 +23,8 @@ struct TemplateData<'a, T> {
|
|||
pub title: &'a str,
|
||||
/// The page's custom scripts.
|
||||
pub scripts: &'a [String],
|
||||
/// the page's custom styles.
|
||||
pub styles: &'a [String],
|
||||
/// Custom template data.
|
||||
#[serde(flatten)]
|
||||
pub extra_data: T,
|
||||
|
@ -216,6 +218,7 @@ impl<'a> SiteBuilder<'a> {
|
|||
page: page_html,
|
||||
title: &title,
|
||||
scripts: &page_metadata.scripts,
|
||||
styles: &page_metadata.styles,
|
||||
extra_data,
|
||||
},
|
||||
)?;
|
||||
|
|
|
@ -70,6 +70,9 @@ pub struct PageMetadata {
|
|||
/// The page's custom scripts, if any.
|
||||
#[serde(default)]
|
||||
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.
|
||||
pub extra: Option<String>,
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue