From 24fe7246320de76b21fb4af68fba4c5d8e53ebfc Mon Sep 17 00:00:00 2001 From: Jordi Smit Date: Sat, 30 Sep 2023 15:43:47 +0200 Subject: [PATCH 1/3] feature: add invoke tasks --- requirements.txt | 1 + tasks.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 requirements.txt create mode 100644 tasks.py diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..73f02e9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +invoke \ No newline at end of file diff --git a/tasks.py b/tasks.py new file mode 100644 index 0000000..efd8745 --- /dev/null +++ b/tasks.py @@ -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") \ No newline at end of file From a32a91cb0c09c5155a6ac6d1f032ff521ff72854 Mon Sep 17 00:00:00 2001 From: Jordi Smit Date: Sat, 30 Sep 2023 15:47:53 +0200 Subject: [PATCH 2/3] fix: pinned hugo version --- .github/workflows/cicd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index a558b08..358e6af 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -34,7 +34,7 @@ jobs: - name: Setup Hugo uses: peaceiris/actions-hugo@v2 with: - hugo-version: latest + hugo-version: v0.112.3 - name: Build run: hugo --minify From 7d16d60c8d6d802907da8448233015b1269997b9 Mon Sep 17 00:00:00 2001 From: Jordi Smit Date: Sat, 30 Sep 2023 15:49:31 +0200 Subject: [PATCH 3/3] fix: pin gohugo version --- .github/workflows/cicd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 358e6af..ffd24c3 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -34,7 +34,7 @@ jobs: - name: Setup Hugo uses: peaceiris/actions-hugo@v2 with: - hugo-version: v0.112.3 + hugo-version: 0.112.3 - name: Build run: hugo --minify