Make only per-site css/js have tags
This commit is contained in:
parent
a7bede494f
commit
2e3dc2289b
@ -88,28 +88,36 @@ pub fn build(logger: &Logger, opt: &Opt, _: &BuildOpt) -> Result<(), Error> {
|
||||
logger.log(LogLevel::DETAILER, "Generating CSS tags");
|
||||
let mut css_string = String::new();
|
||||
let mut css_list = config.global_config.website.css.clone();
|
||||
if let Some(mut list) = config.page_config.page.css.clone() {
|
||||
css_list.append(&mut list);
|
||||
}
|
||||
|
||||
for item in css_list {
|
||||
let data = Template::css_tag_data_from(item);
|
||||
let data = Template::css_tag_data_from(item, false);
|
||||
css_string += &*css_tag_template.render(&data);
|
||||
}
|
||||
|
||||
if let Some(mut list) = config.page_config.page.css.clone() {
|
||||
for item in list {
|
||||
let data = Template::css_tag_data_from(item, true);
|
||||
css_string += &*css_tag_template.render(&data);
|
||||
}
|
||||
}
|
||||
|
||||
// Generate JS tags
|
||||
logger.log(LogLevel::DETAILER, "Generating JS tags");
|
||||
let mut js_string = String::new();
|
||||
let mut js_list = config.global_config.website.javascript.clone();
|
||||
if let Some(mut list) = config.page_config.page.javascript.clone() {
|
||||
js_list.append(&mut list);
|
||||
}
|
||||
|
||||
for item in js_list {
|
||||
let data = Template::css_tag_data_from(item);
|
||||
let data = Template::css_tag_data_from(item, false);
|
||||
js_string += &*js_tag_template.render(&data);
|
||||
}
|
||||
|
||||
if let Some(mut list) = config.page_config.page.javascript.clone() {
|
||||
for item in list {
|
||||
let data = Template::css_tag_data_from(item, true);
|
||||
js_string += &*js_tag_template.render(&data);
|
||||
}
|
||||
}
|
||||
|
||||
// Generate and render Injections
|
||||
logger.log(LogLevel::DETAILER, "Rendering injections.");
|
||||
let (before_navbar, before_content, after_content) =
|
||||
|
@ -63,9 +63,10 @@ impl Template {
|
||||
result
|
||||
}
|
||||
|
||||
pub fn css_tag_data_from(link: String) -> Data {
|
||||
pub fn css_tag_data_from(link: String, is_per_site: bool) -> Data {
|
||||
hashmap!(
|
||||
"link".to_owned() => link
|
||||
"link".to_owned() => link,
|
||||
"class".to_owned() => if is_per_site {"_default_js_meta".to_owned()} else {String::new()}
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ function change_page(new_document, new_url, no_pop_state) {
|
||||
document.querySelector("link[rel*='icon']").href = new_favicon;
|
||||
|
||||
// Replace css/js tags
|
||||
let list = document.getElementsByClassName("._default_js_meta");
|
||||
let list = document.getElementsByClassName("_default_js_meta");
|
||||
for (i in list) {
|
||||
let element = list[0];
|
||||
if (element !== undefined) {
|
||||
@ -74,7 +74,7 @@ function change_page(new_document, new_url, no_pop_state) {
|
||||
}
|
||||
}
|
||||
|
||||
let new_list = new_document.getElementsByClassName("._default_js_meta");
|
||||
let new_list = new_document.getElementsByClassName("_default_js_meta");
|
||||
for (i in new_list) {
|
||||
let element = new_list[0];
|
||||
if (element !== undefined) {
|
||||
|
@ -1 +1 @@
|
||||
<link class="._default_js_meta" rel="stylesheet" href="{{link}}">
|
||||
<link class="{{class}}" rel="stylesheet" href="{{link}}">
|
@ -1 +1 @@
|
||||
<script class="._default_js_meta" type="application/javascript" src="{{link}}"></script>
|
||||
<script class="{{class}}" type="application/javascript" src="{{link}}"></script>
|
Loading…
Reference in New Issue
Block a user