|
@@ -55,6 +55,7 @@ pub struct Paginator<'a> { |
|
|
pub permalink: String, |
|
|
pub permalink: String, |
|
|
path: String, |
|
|
path: String, |
|
|
pub paginate_path: String, |
|
|
pub paginate_path: String, |
|
|
|
|
|
template: String, |
|
|
/// Whether this is the index section, we need it for the template name |
|
|
/// Whether this is the index section, we need it for the template name |
|
|
is_index: bool, |
|
|
is_index: bool, |
|
|
} |
|
|
} |
|
@@ -73,6 +74,7 @@ impl<'a> Paginator<'a> { |
|
|
path: section.path.clone(), |
|
|
path: section.path.clone(), |
|
|
paginate_path: section.meta.paginate_path.clone(), |
|
|
paginate_path: section.meta.paginate_path.clone(), |
|
|
is_index: section.is_index(), |
|
|
is_index: section.is_index(), |
|
|
|
|
|
template: section.get_template_name().to_string(), |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
paginator.fill_pagers(library); |
|
|
paginator.fill_pagers(library); |
|
@@ -100,6 +102,7 @@ impl<'a> Paginator<'a> { |
|
|
.clone() |
|
|
.clone() |
|
|
.unwrap_or_else(|| "pages".to_string()), |
|
|
.unwrap_or_else(|| "pages".to_string()), |
|
|
is_index: false, |
|
|
is_index: false, |
|
|
|
|
|
template: format!("{}/single.html", taxonomy.kind.name), |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
paginator.fill_pagers(library); |
|
|
paginator.fill_pagers(library); |
|
@@ -204,22 +207,20 @@ impl<'a> Paginator<'a> { |
|
|
) -> Result<String> { |
|
|
) -> Result<String> { |
|
|
let mut context = Context::new(); |
|
|
let mut context = Context::new(); |
|
|
context.insert("config", &config); |
|
|
context.insert("config", &config); |
|
|
let template_name = match self.root { |
|
|
|
|
|
|
|
|
match self.root { |
|
|
PaginationRoot::Section(s) => { |
|
|
PaginationRoot::Section(s) => { |
|
|
context |
|
|
context |
|
|
.insert("section", &SerializingSection::from_section_basic(s, Some(library))); |
|
|
.insert("section", &SerializingSection::from_section_basic(s, Some(library))); |
|
|
s.get_template_name() |
|
|
|
|
|
} |
|
|
} |
|
|
PaginationRoot::Taxonomy(t) => { |
|
|
PaginationRoot::Taxonomy(t) => { |
|
|
context.insert("taxonomy", &t.kind); |
|
|
context.insert("taxonomy", &t.kind); |
|
|
format!("{}/single.html", t.kind.name) |
|
|
|
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
context.insert("current_url", &pager.permalink); |
|
|
context.insert("current_url", &pager.permalink); |
|
|
context.insert("current_path", &pager.path); |
|
|
context.insert("current_path", &pager.path); |
|
|
context.insert("paginator", &self.build_paginator_context(pager)); |
|
|
context.insert("paginator", &self.build_paginator_context(pager)); |
|
|
|
|
|
|
|
|
render_template(&template_name, tera, &context, &config.theme) |
|
|
|
|
|
|
|
|
render_template(&self.template, tera, &context, &config.theme) |
|
|
.chain_err(|| format!("Failed to render pager {}", pager.index)) |
|
|
.chain_err(|| format!("Failed to render pager {}", pager.index)) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|