Skip to content

Commit 1b31963

Browse files
committed
Add a blog post archetype
1 parent 002cb9f commit 1b31963

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

archetypes/blog.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
categories:
3+
-
4+
date: {{ now.Format "2006-01-02" }}
5+
draft: true
6+
tags:
7+
-
8+
title: {{ replace .Name "-" " " | title }}
9+
---

dev

+16-11
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,25 @@ subparsers = parser.add_subparsers(metavar='<command>', title='commands')
1919

2020
DOCKER_RUN = [
2121
'docker', 'run', '--init', '-it', '--rm', '-v',
22-
f'{os.getcwd()}:/src:cached', '-w=/src', '-p', '1313:1313',
22+
f'{os.getcwd()}:/src:cached', '-w=/src'
2323
]
2424

25-
DOCKER_HUGO = DOCKER_RUN + ['cibuilds/hugo:0.41']
26-
27-
DOCKER_NODE = DOCKER_RUN + ['node:10.4.0-alpine']
28-
2925
def command(help):
3026
def decorator(func):
3127
parser = subparsers.add_parser(func.__name__, help=help)
3228
parser.set_defaults(func=func)
3329
return func
3430
return decorator
3531

32+
def run_in_hugo(command, bind_port=False):
33+
return run(
34+
DOCKER_RUN + (['-p', '1313:1313'] if bind_port else []) +
35+
['cibuilds/hugo:0.41'] + command
36+
).returncode
37+
38+
def run_in_node(command):
39+
return run(DOCKER_RUN + ['node:10.4.0-alpine'] + command).returncode
40+
3641
def open_in_browser():
3742
site = 'http://localhost:1313'
3843
while True:
@@ -78,30 +83,30 @@ def algolia(args, remaining):
7883
return run(['atomic-algolia']).returncode
7984
if which('npx'):
8085
return run(['npx', 'atomic-algolia']).returncode
81-
return run(DOCKER_NODE + ['npx', 'atomic-algolia']).returncode
86+
return run_in_node(['npx', 'atomic-algolia'])
8287

8388
@command('Run a Hugo command')
8489
def hugo(args, remaining):
85-
return run(DOCKER_HUGO + ['hugo'] + (remaining or [])).returncode
90+
return run_in_hugo(['hugo'] + (remaining or []))
8691

8792
@command('Lint the resulting HTML')
8893
def lint(args, remaining):
8994
rc = hugo(None, None)
9095
if rc:
9196
return rc
92-
return run(DOCKER_HUGO + [
97+
return run_in_hugo([
9398
'htmlproofer', '--check-favicon', '--check-html', '--check-opengraph',
9499
'--disable-external', 'public'
95-
]).returncode
100+
])
96101

97102
@command('Open a shell')
98103
def sh(args, remaining):
99-
return run(DOCKER_HUGO + ['sh']).returncode
104+
return run_in_hugo(['sh'])
100105

101106
@command('Start development')
102107
def start(args, remaining):
103108
Thread(target=open_in_browser).start()
104-
run(DOCKER_HUGO + ['hugo', 'server', '--bind', '0.0.0.0', '--buildDrafts'])
109+
run_in_hugo(['hugo', 'server', '--bind', '0.0.0.0', '--buildDrafts'], True)
105110

106111
if __name__ == '__main__':
107112
if len(sys.argv) > 1:

0 commit comments

Comments
 (0)