pulumi-hugo-cn/scripts/content/new-learn-topic.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2021-07-09 08:16:55 -07:00
#!/bin/bash
set -o errexit -o pipefail
module=""
topic=""
2022-02-02 13:11:53 -08:00
content_dir="themes/default/content"
2021-07-09 08:16:55 -07:00
prompt_for_module_name() {
read -p "Module name (e.g., pulumi-101-aws): " module
2022-02-02 13:11:53 -08:00
if [[ ! -z "$module" && -d "${content_dir}/learn/${module}" ]]; then
2021-07-09 08:16:55 -07:00
return
fi
echo "Couldn't find a module with that name. Make sure you're using the path as listed under content/learn."
echo
prompt_for_module_name
}
prompt_for_topic_name() {
read -p "Topic name (e.g., basics): " topic
if [ ! -z "$topic" ]; then
2022-02-02 13:11:53 -08:00
hugo new --kind learn/topic --contentDir "${content_dir}" "learn/${module}/${topic}"
2021-07-09 08:16:55 -07:00
return
fi
echo "Please give the topic a name."
echo
prompt_for_topic_name
}
echo "So, you want to make a new Learn Pulumi topic? Great! 🙌"
echo
echo "Step 1:"
echo "What is the path name of the module you want to write for?"
echo
prompt_for_module_name
echo
echo "Step 2:"
echo "Now give your new topic 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