Skip to content

Commit

Permalink
style: Move like code together
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed Page committed Feb 13, 2020
1 parent 3cbfc15 commit 160c395
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions src/cobalt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,37 +294,6 @@ fn sort_pages(posts: &mut Vec<Document>, collection: &Collection) -> Result<()>
Ok(())
}

fn parse_drafts(
drafts_root: &path::Path,
draft_files: &files::Files,
documents: &mut Vec<Document>,
collection: &Collection,
) -> Result<()> {
let rel_real = collection
.pages
.subtree()
.strip_prefix(collection.pages.root())
.expect("subtree is under root");
for file_path in draft_files.files() {
// Provide a fake path as if it was not a draft
let rel_src = file_path
.strip_prefix(&drafts_root)
.expect("file was found under the root");
let new_path = rel_real.join(rel_src);

let default_front = cobalt_config::Frontmatter {
is_draft: Some(true),
..Default::default()
}
.merge(&collection.default);

let doc = Document::parse(&file_path, &new_path, default_front)
.with_context(|_| failure::format_err!("Failed to parse {}", rel_src.display()))?;
documents.push(doc);
}
Ok(())
}

fn find_layouts(layouts: &path::Path) -> Result<files::Files> {
let mut files = files::FilesBuilder::new(layouts)?;
files.ignore_hidden(false)?;
Expand Down Expand Up @@ -364,6 +333,37 @@ fn parse_layouts(files: &files::Files) -> HashMap<String, String> {
.collect()
}

fn parse_drafts(
drafts_root: &path::Path,
draft_files: &files::Files,
documents: &mut Vec<Document>,
collection: &Collection,
) -> Result<()> {
let rel_real = collection
.pages
.subtree()
.strip_prefix(collection.pages.root())
.expect("subtree is under root");
for file_path in draft_files.files() {
// Provide a fake path as if it was not a draft
let rel_src = file_path
.strip_prefix(&drafts_root)
.expect("file was found under the root");
let new_path = rel_real.join(rel_src);

let default_front = cobalt_config::Frontmatter {
is_draft: Some(true),
..Default::default()
}
.merge(&collection.default);

let doc = Document::parse(&file_path, &new_path, default_front)
.with_context(|_| failure::format_err!("Failed to parse {}", rel_src.display()))?;
documents.push(doc);
}
Ok(())
}

fn parse_pages(
page_files: &files::Files,
collection: &Collection,
Expand Down

0 comments on commit 160c395

Please sign in to comment.