-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen-static
executable file
·37 lines (29 loc) · 922 Bytes
/
gen-static
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
from flask_frozen import Freezer
from app import app
from pathlib import Path
freezer = Freezer(app)
app.config['FREEZER_DESTINATION'] = 'docs'
def rmtree(root):
for p in root.iterdir():
if p.is_dir():
rmtree(p)
else:
p.unlink()
if __name__ == '__main__':
print('removing docs/ directory')
docs_dir = Path('docs/')
rmtree(docs_dir)
print('generating static site')
freezer.freeze()
print('renaming files')
tidbits_path = docs_dir / 'tidbits'
tidbits_path.rename(docs_dir / 'index.html')
for path in docs_dir.iterdir():
if path.is_file() and path.suffix == '':
path.rename(docs_dir / f'{path.name}.html')
print('touching nojekyll file')
(docs_dir / '.nojekyll').touch()
print('writing CNAME file')
with open(docs_dir / 'CNAME', 'w') as out:
out.write('seandontlai.com')