Fix some index related bugs
This commit is contained in:
parent
be2f01b5bc
commit
404240ef82
|
@ -4,6 +4,8 @@
|
|||
|
||||
- Fix shortcodes without arguments being ignored
|
||||
- Fix shortcodes with markdown chars (_, *, etc) in name and args being ignored
|
||||
- Fix subsections of index not being filled without a `_index.md`
|
||||
- Fix permalink generation for index page
|
||||
|
||||
|
||||
## 0.2.1 (2017-10-17)
|
||||
|
|
|
@ -108,7 +108,7 @@ impl Config {
|
|||
|
||||
/// Makes a url, taking into account that the base url might have a trailing slash
|
||||
pub fn make_permalink(&self, path: &str) -> String {
|
||||
let trailing_bit = if path.ends_with('/') { "" } else { "/" };
|
||||
let trailing_bit = if path.ends_with('/') || path.is_empty() { "" } else { "/" };
|
||||
|
||||
// Index section with a base url that has a trailing slash
|
||||
if self.base_url.ends_with('/') && path == "/" {
|
||||
|
@ -243,6 +243,21 @@ hello = "world"
|
|||
assert_eq!(config.unwrap().extra.unwrap().get("hello").unwrap().as_str().unwrap(), "world");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_make_url_index_page_with_non_trailing_slash_url() {
|
||||
let mut config = Config::default();
|
||||
config.base_url = "http://vincent.is".to_string();
|
||||
assert_eq!(config.make_permalink(""), "http://vincent.is/");
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn can_make_url_index_page_with_railing_slash_url() {
|
||||
let mut config = Config::default();
|
||||
config.base_url = "http://vincent.is/".to_string();
|
||||
assert_eq!(config.make_permalink(""), "http://vincent.is/");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_make_url_with_non_trailing_slash_base_url() {
|
||||
let mut config = Config::default();
|
||||
|
|
|
@ -207,7 +207,7 @@ impl Site {
|
|||
if !self.sections.contains_key(&index_path) {
|
||||
let mut index_section = Section::default();
|
||||
index_section.permalink = self.config.make_permalink("");
|
||||
// TODO: need to insert into permalinks too
|
||||
index_section.file.parent = self.base_path.join("content");
|
||||
self.sections.insert(index_path, index_section);
|
||||
}
|
||||
|
||||
|
@ -736,8 +736,12 @@ impl Site {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Used only on reload
|
||||
pub fn render_index(&self) -> Result<()> {
|
||||
self.render_section(&self.sections[&self.base_path.join("content").join("_index.md")], false)
|
||||
self.render_section(
|
||||
&self.sections[&self.base_path.join("content").join("_index.md")],
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
/// Renders all sections
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
+++
|
||||
title = "Index"
|
||||
+++
|
Loading…
Reference in a new issue