Now that I have custom tasks for building and serving my Hugo site in Visual Studio Code, I wanted to create posts quickly without having to remember the hugo
command. So, this is what I did:
|
|
The Variable Substitution section of the Visual Studio docs provides information on getting input from the user.
First, I defined the inputs
by providing the id
, description
, and type
. Then the most interesting part:
The command:
|
|
does three (3) things using bash:
Save the input text into a variable named
title
1
title="${input:title}"
Replace spaces in the
title
variable with dashes and store the output in another variable namedslug
:1
slug="${title// /-}"
Execute
hugo
command to create the content file:1
hugo new content/post/${slug,,}/index.md --source ./src
This last command converts the contents of the
slug
variable to lowercase. Pretty neat!
So far I’m pretty pleased with my experience with the Hugo static site generator.