add new post script
This commit is contained in:
parent
6db201b31a
commit
ca8c61d2b2
1 changed files with 32 additions and 1 deletions
33
flake.nix
33
flake.nix
|
|
@ -35,6 +35,37 @@
|
||||||
pkgs.rsyncy
|
pkgs.rsyncy
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
new-post = pkgs.writeShellApplication {
|
||||||
|
name = "new-post";
|
||||||
|
|
||||||
|
text = ''
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
echo "usage: $0 <slug> [<title> [<description>]]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
filename="$1.mdx"
|
||||||
|
title=''${2:-"CHANGEME"}
|
||||||
|
description=''${3:-"CHANGEME"}
|
||||||
|
|
||||||
|
if [ -e "site-src/$filename" ]; then
|
||||||
|
echo "$filename already exists!"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO: don't hardcode timezone (%z doesn't quite work)
|
||||||
|
cat > "site-src/$filename" <<EOF
|
||||||
|
---
|
||||||
|
title: $title
|
||||||
|
description: $description
|
||||||
|
tags: post,short
|
||||||
|
date: $(date +'%Y-%m-%d %H:%M:%S -5')
|
||||||
|
---
|
||||||
|
bla bla bla
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
devShell = pkgs.mkShell {
|
devShell = pkgs.mkShell {
|
||||||
|
|
@ -48,7 +79,7 @@
|
||||||
build = eleventy-shortcut { name = "build"; };
|
build = eleventy-shortcut { name = "build"; };
|
||||||
serve = eleventy-shortcut { name = "serve"; args = ["--serve"]; };
|
serve = eleventy-shortcut { name = "serve"; args = ["--serve"]; };
|
||||||
watch = eleventy-shortcut { name = "watch"; args = ["--watch"]; };
|
watch = eleventy-shortcut { name = "watch"; args = ["--watch"]; };
|
||||||
inherit deploy;
|
inherit deploy new-post;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue