forked from austinjavascript/austinjavascript.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckposts
More file actions
executable file
·21 lines (15 loc) · 776 Bytes
/
checkposts
File metadata and controls
executable file
·21 lines (15 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python
from datetime import datetime
import sys
import os
for f in os.listdir('_posts'):
post_date_str = '-'.join(f.split('-')[:3])
post_datetime = datetime.strptime(post_date_str, '%Y-%m-%d')
if post_datetime > datetime.now():
sys.stderr.write("""There is a post named {0}, which is in the future, so it won't be published.
Presumably you're adding a post because you want it to show up on the site, but Jekyll consider's the post's name to be the *publish* date, so if that's in the future, it won't generate the page for it.
You probably want to run a:
git mv {0} {1}
And commit+push the update.
""".format('_posts/' + f, '_posts/' + datetime.now().strftime('%Y-%m-%d') + '-' + '-'.join(f.split('-')[3:])))
sys.exit(42)