|
@@ -36,10 +36,7 @@ fn parse_post(path: path::PathBuf) -> Post {
|
36
|
36
|
}
|
37
|
37
|
}
|
38
|
38
|
|
39
|
|
-fn read_posts_dir() -> fs::ReadDir {
|
40
|
|
- let cwd = env::current_dir()
|
41
|
|
- .expect("Couldn't read current directory")
|
42
|
|
- .join("posts");
|
|
39
|
+fn read_posts_dir(cwd: &path::PathBuf) -> fs::ReadDir {
|
43
|
40
|
match fs::read_dir(cwd) {
|
44
|
41
|
Ok(posts) => posts,
|
45
|
42
|
Err(err) => panic!(err),
|
|
@@ -47,7 +44,9 @@ fn read_posts_dir() -> fs::ReadDir {
|
47
|
44
|
}
|
48
|
45
|
|
49
|
46
|
fn main() {
|
50
|
|
- let post_paths = read_posts_dir();
|
|
47
|
+ let cwd = env::current_dir()
|
|
48
|
+ .expect("Couldn't read current directory");
|
|
49
|
+ let post_paths = read_posts_dir(&cwd.join("posts"));
|
51
|
50
|
for path in post_paths {
|
52
|
51
|
match path {
|
53
|
52
|
Ok(p) => {
|