Utility script to create a new docs page with the correct ID

Signed-off-by: Solomon Hykes <solomon@dagger.io>
This commit is contained in:
Solomon Hykes 2022-02-16 18:52:12 +00:00
parent c08d9d9e4c
commit 724be92bb4

28
docs/new.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
## Create a new documentation article
function new() {
local name
name="$1"
if [ -z "$name" ]; then
echo >&2 "Usage: $0 NAME"
return 1
fi
local last
last="$(
find . -name '[0-9]*.md' |
sed -E -e 's/^.*\/([0-9]+)-([^\/]*)\.md/\1/' |
sort -u -n |
tail -n 1
)"
local next
((next="$last"+1))
local filename="$next-$name.md"
echo "Creating $filename"
touch "$filename"
}
new "$@"