This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/docs/new.sh
user.email d20ffbe8be website: hardcode version banner for 0.1 docs
O.1 docs is deprecated. Let's inform user to switch the the latest version

Signed-off-by: user.email <jf@dagger.io>
2022-04-13 15:58:51 +02:00

33 lines
487 B
Bash
Executable File

#!/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"
cat <<- EOF > "$filename"
---
slug: /$next/$name
displayed_sidebar: "0.2"
---
EOF
}
new "$@"