Skip to content

Commit c7d58b3

Browse files
committed
Additional Theme
1 parent 8ec98b2 commit c7d58b3

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/config.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,8 @@ pub struct HtmlConfig {
496496
pub google_analytics: Option<String>,
497497
/// Additional CSS stylesheets to include in the rendered page's `<head>`.
498498
pub additional_css: Vec<PathBuf>,
499+
/// Additional theme.
500+
pub additional_theme: Vec<PathBuf>,
499501
/// Additional JS scripts to include at the bottom of the rendered page's
500502
/// `<body>`.
501503
pub additional_js: Vec<PathBuf>,
@@ -553,6 +555,7 @@ impl Default for HtmlConfig {
553555
copy_fonts: true,
554556
google_analytics: None,
555557
additional_css: Vec::new(),
558+
additional_theme: Vec::new(),
556559
additional_js: Vec::new(),
557560
fold: Fold::default(),
558561
playground: Playground::default(),
@@ -742,6 +745,7 @@ mod tests {
742745
curly-quotes = true
743746
google-analytics = "123456"
744747
additional-css = ["./foo/bar/baz.css"]
748+
additional-theme = ["foobar"]
745749
git-repository-url = "https://foo.com/"
746750
git-repository-icon = "fa-code-fork"
747751
@@ -788,6 +792,7 @@ mod tests {
788792
curly_quotes: true,
789793
google_analytics: Some(String::from("123456")),
790794
additional_css: vec![PathBuf::from("./foo/bar/baz.css")],
795+
additional_theme: vec![PathBuf::from("foobar")],
791796
theme: Some(PathBuf::from("./themedir")),
792797
default_theme: Some(String::from("rust")),
793798
playground: playground_should_be,
@@ -968,6 +973,7 @@ mod tests {
968973
curly-quotes = true
969974
google-analytics = "123456"
970975
additional-css = ["custom.css", "custom2.css"]
976+
additional-theme = ["foobar"]
971977
additional-js = ["custom.js"]
972978
"#;
973979

@@ -993,6 +999,7 @@ mod tests {
993999
curly_quotes: true,
9941000
google_analytics: Some(String::from("123456")),
9951001
additional_css: vec![PathBuf::from("custom.css"), PathBuf::from("custom2.css")],
1002+
additional_theme: vec![PathBuf::from("foobar")],
9961003
additional_js: vec![PathBuf::from("custom.js")],
9971004
..Default::default()
9981005
};

src/renderer/html_handlebars/hbs_renderer.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,18 @@ fn make_data(
698698
data.insert("additional_css".to_owned(), json!(css));
699699
}
700700

701+
// Add check to see if there are additional themes
702+
if !html_config.additional_theme.is_empty() {
703+
let mut theme = Vec::new();
704+
for name in &html_config.additional_theme {
705+
match name.strip_prefix(root) {
706+
Ok(p) => theme.push(p.to_str().expect("Could not convert to str")),
707+
Err(_) => theme.push(name.to_str().expect("Could not convert to str")),
708+
}
709+
}
710+
data.insert("additional_theme".to_owned(), json!(theme));
711+
}
712+
701713
// Add check to see if there is an additional script
702714
if !html_config.additional_js.is_empty() {
703715
let mut js = Vec::new();

0 commit comments

Comments
 (0)