pulumi-hugo-cn/scripts/content/new-learn-module.sh
2022-02-02 13:11:53 -08:00

50 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
set -o errexit -o pipefail
module=""
topic=""
content_dir="themes/default/content"
prompt_for_module_name() {
read -p "Module name (e.g., pulumi-101-aws): " module
if [ ! -z "$module" ]; then
hugo new --kind learn/module --contentDir "${content_dir}" "learn/${module}"
return
fi
echo "Please give the module a name."
prompt_for_module_name
}
prompt_for_topic_name() {
read -p "Topic name (e.g., basics): " topic
if [ ! -z "$topic" ]; then
hugo new --kind learn/topic --contentDir "${content_dir}" "learn/${module}/${topic}"
return
fi
echo "Please give the topic a name."
prompt_for_topic_name
}
echo "So, you want to make a new Learn Pulumi module? Awesome! 🙌"
echo
echo "Step 1:"
echo "First, give the module a URL- and SEO-friendly name.
For example, to create a new module that'll live at
https://pulumi.com/learn/pulumi-101, type 'pulumi-101'."
echo
prompt_for_module_name
echo
echo "Step 2:"
echo "Now give your new module at least one new topic, also expressed
as a URL-friendly name. For example, to create a new topic under ${module}
that'll live at https://pulumi.com/learn/${module}/basics, type 'basics'."
echo
prompt_for_topic_name