File tree 1 file changed +11
-5
lines changed
1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,12 @@ function date_from_filename () {
8
8
}
9
9
10
10
11
+ function date_from_front_matter() {
12
+ local file=" ${1} "
13
+ cat " $file " |
14
+ perl -n -e ' $front_matter .= $_ if /---/.../---/; END { print $1 if $front_matter =~ /date:\s+([0-9-]+)/;}'
15
+ }
16
+
11
17
12
18
function main () {
13
19
# Directory containing posts
@@ -25,16 +31,16 @@ function main () {
25
31
date_from_filename=$( date_from_filename " $filename " )
26
32
27
33
# Extract date from front matter
28
- frontmatter_date =$( cat " $file " | perl -n -e ' $front_matter .= $_ if /---/.../---/; END { print $1 if $front_matter =~ /date:\s+([0-9-]+)/;} ' )
34
+ date_from_front_matter =$( date_from_front_matter " ${ file} " )
29
35
30
36
# Compare file date with front matter date
31
- if [[ " $date_from_filename " = ' ' ]] || [[ " $date_from_filename " != " $frontmatter_date " ]]; then
37
+ if [[ " $date_from_filename " = ' ' ]] || [[ " $date_from_filename " != " $date_from_front_matter " ]]; then
32
38
echo " Inconsist or missing date info: $file "
33
- echo " Date From Filename: '$date_from_filename '"
34
- echo " Front matter date: ' $frontmatter_date '"
39
+ echo " Date From Filename: '$date_from_filename '"
40
+ echo " Date From Front Matter: ' $date_from_front_matter '"
35
41
inconsistent=true
36
42
else
37
- # echo "Consistent|$file|$filename|$date_from_filename|$frontmatter_date |"
43
+ # echo "Consistent|$file|$filename|$date_from_filename|$date_from_front_matter |"
38
44
:
39
45
fi
40
46
done
You can’t perform that action at this time.
0 commit comments