From f027208f582c2d2e3a92212959939f7a0fc091ac Mon Sep 17 00:00:00 2001 From: slonkazoid Date: Sat, 28 Dec 2024 21:25:51 +0300 Subject: [PATCH] change arguments --- README.md | 8 +++++++- blag | 9 ++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6a629e2..e279a67 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,12 @@ run `blag` on your post: Mon Dec 16 22:42:00 +03 2024

``` +### arguments + +blagposts rendered with the blag script will have arguments much like a regular +shellscript, except you should reference `$path` instead of `$0` when getting +the script path. `$0` is the path of blag itself. + ## bingus-blog integration set `engine = "blag"` in your configuration file. the naming format is @@ -142,7 +148,7 @@ APIs in blag (do not do this). due to how blag works, the hash of the query params is stored alongside the mtime of the post file. you can only tell bingus-blog "hey, don't cache me!" from a post, but sometimes you need to invalidate the existing cache for all -query param combinations. to do that, `touch -c "$1"` from your post file. +query param combinations. to do that, `touch -c "$path"` from your post file. this sets the mtime for the post to right now, invalidating the reference to it as bingus-blog believes that the contents have changed. diff --git a/blag b/blag index 3cb7cf8..4f18101 100755 --- a/blag +++ b/blag @@ -87,14 +87,17 @@ codeblock() { } render() {( - birth=$(stat -c'%W' "$1") + path=$1 + shift + + birth=$(stat -c'%W' "$path") if (( birth > 0 )); then CREATED_AT=$(date --rfc-3339=seconds -d "@$birth") fi - MODIFIED_AT=$(date --rfc-3339=seconds -d "@$(stat -c '%Y' "$1")") + MODIFIED_AT=$(date --rfc-3339=seconds -d "@$(stat -c '%Y' "$path")") #shellcheck disable=SC1090 - . "$1" + . "$path" "$@" )} print_help() {