Skip to content

Commit

Permalink
feat(page): page.file.parent variable
Browse files Browse the repository at this point in the history
This can be used for referencing assets in the folder the file came
from.

Fixes cobalt-org#338
  • Loading branch information
epage committed Jan 6, 2018
1 parent 8edb3e6 commit dce1d59
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,12 @@ fn document_attributes(front: &cobalt_model::Frontmatter,
// Reason for `file`:
// - Allow access to assets in the original location
// - Ease linking back to page's source
let file: liquid::Object = vec![("permalink".to_owned(),
liquid::Value::str(source_file.to_str().unwrap_or("")))]
.into_iter()
.collect();
let file: liquid::Object =
vec![("permalink".to_owned(), liquid::Value::str(source_file.to_str().unwrap_or(""))),
("parent".to_owned(),
liquid::Value::str(source_file.parent().and_then(Path::to_str).unwrap_or("")))]
.into_iter()
.collect();
let attributes =
vec![("permalink".to_owned(), liquid::Value::str(url_path)),
("title".to_owned(), liquid::Value::str(&front.title)),
Expand Down

0 comments on commit dce1d59

Please sign in to comment.