Skip to content

Commit

Permalink
feature: add invoke tasks (#11)
Browse files Browse the repository at this point in the history
* feature: add invoke tasks

* fix: pinned hugo version

* fix: pin gohugo version
  • Loading branch information
j0rd1smit authored Sep 30, 2023
1 parent 26c193d commit dd63b9d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: latest
hugo-version: 0.112.3

- name: Build
run: hugo --minify
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoke
35 changes: 35 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import datetime
import webbrowser

from invoke import task, Context


@task
def build(ctx: Context) -> None:
ctx.run("hugo --minify")


@task
def dev(ctx: Context) -> None:
webbrowser.open('http://localhost:1313/')
ctx.run("hugo server -D")


@task
def add_blog(ctx: Context, title: str, prefix: str | None = None) -> None:
prefix = prefix or _get_timestamp()
title = title.replace(" ", "-").lower()
path = f"blog/{prefix}-{title}"

ctx.run(f"hugo new --kind post {path}")

@task
def add_til(ctx: Context, title: str, prefix: str | None = None) -> None:
prefix = prefix or _get_timestamp()
title = title.replace(" ", "-").lower()
path = f"til/{prefix}-{title}"

ctx.run(f"hugo new --kind post {path}")

def _get_timestamp() -> str:
return datetime.datetime.now().strftime("%Y-%m-%d")

0 comments on commit dd63b9d

Please sign in to comment.