|
@@ -52,22 +52,22 @@ pub fn read_entry_dir(cwd: &path::Path) -> Vec<fs::DirEntry> {
|
52
|
52
|
|
53
|
53
|
pub fn parse_entry(kind: EntryKind, contents: &str, path: &path::Path) -> Entry {
|
54
|
54
|
lazy_static! {
|
55
|
|
- static ref re_with_date: Regex =
|
|
55
|
+ static ref RE_WITH_DATE: Regex =
|
56
|
56
|
Regex::new(r"^# (?P<title>.*) \| (?P<date>\d{4}-\d{2}-\d{2})\n\n(?s)(?P<body>.*)")
|
57
|
57
|
.unwrap();
|
58
|
|
- static ref re_without_date: Regex =
|
|
58
|
+ static ref RE_WITHOUT_DATE: Regex =
|
59
|
59
|
Regex::new(r"^# (?P<title>.*)\n\n(?s)(?P<body>.*)").unwrap();
|
60
|
|
- static ref slug_re: Regex = Regex::new(r"(?P<slug>\S+).md").unwrap();
|
|
60
|
+ static ref SLUG_RE: Regex = Regex::new(r"(?P<slug>\S+).md").unwrap();
|
61
|
61
|
}
|
62
|
62
|
|
63
|
63
|
let filename = &path.file_name().unwrap().to_str().unwrap();
|
64
|
|
- let slug = slug_re
|
|
64
|
+ let slug = SLUG_RE
|
65
|
65
|
.captures(filename)
|
66
|
66
|
.expect("Couldn't parse slug from filename")["slug"]
|
67
|
67
|
.to_string();
|
68
|
68
|
|
69
|
69
|
if kind == EntryKind::Post {
|
70
|
|
- let captures = &re_with_date
|
|
70
|
+ let captures = &RE_WITH_DATE
|
71
|
71
|
.captures(&contents)
|
72
|
72
|
.expect("Couldn't parse post");
|
73
|
73
|
let title = captures["title"].to_string();
|
|
@@ -83,7 +83,7 @@ pub fn parse_entry(kind: EntryKind, contents: &str, path: &path::Path) -> Entry
|
83
|
83
|
date,
|
84
|
84
|
}
|
85
|
85
|
} else {
|
86
|
|
- let captures = &re_without_date
|
|
86
|
+ let captures = &RE_WITHOUT_DATE
|
87
|
87
|
.captures(&contents)
|
88
|
88
|
.expect("Couldn't parse page");
|
89
|
89
|
let title = captures["title"].to_string();
|