Mostly audio stuff
This commit is contained in:
parent
bdd00ec9e8
commit
2f5f4dbea4
28 changed files with 811 additions and 710 deletions
63
new.sh
63
new.sh
|
|
@ -1,15 +1,40 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Script to create new Hugo content w/ filename sanitization
|
||||
# Usage: ./new.sh <type> <title>
|
||||
|
||||
# Usage: ./new.sh [-d] [-s] <type> <title>
|
||||
# -d: Add date prefix (YYYY-MM-DD)
|
||||
# -s: Single page format (.md instead of /)
|
||||
set -e
|
||||
|
||||
# Initialize flags
|
||||
ADD_DATE=false
|
||||
SINGLE_PAGE=false
|
||||
|
||||
# Parse flags
|
||||
while getopts "ds" opt; do
|
||||
case $opt in
|
||||
d)
|
||||
ADD_DATE=true
|
||||
;;
|
||||
s)
|
||||
SINGLE_PAGE=true
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Shift past the options
|
||||
shift $((OPTIND-1))
|
||||
|
||||
# Check if required arguments are provided
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "Usage: $0 <type> <title>"
|
||||
echo "Example: $0 blog 'My Awesome Post'"
|
||||
exit 1
|
||||
echo "Usage: $0 [-d] [-s] <type> <title>"
|
||||
echo " -d: Add date prefix (YYYY-MM-DD)"
|
||||
echo " -s: Single page format (.md instead of /)"
|
||||
echo "Example: $0 -d -s blog 'My Awesome Post'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TYPE="$1"
|
||||
|
|
@ -17,15 +42,25 @@ shift
|
|||
TITLE="$*"
|
||||
|
||||
SAFE_TITLE=$(echo "$TITLE" | \
|
||||
tr '[:upper:]' '[:lower:]' | \
|
||||
sed 's/ /-/g' | \
|
||||
sed 's/\//-/g' | \
|
||||
sed 's/[^a-z0-9_-]//g' | \
|
||||
sed 's/-\+/-/g' | \
|
||||
sed 's/^-//;s/-$//')
|
||||
tr '[:upper:]' '[:lower:]' | \
|
||||
sed 's/ /-/g' | \
|
||||
sed 's/\//-/g' | \
|
||||
sed 's/[^a-z0-9_-]//g' | \
|
||||
sed 's/-\+/-/g' | \
|
||||
sed 's/^-//;s/-$//')
|
||||
|
||||
# Construct the filename with date
|
||||
FILENAME="${SAFE_TITLE}/"
|
||||
# Add date prefix if flag is set
|
||||
if [ "$ADD_DATE" = true ]; then
|
||||
DATE_PREFIX=$(date +%Y-%m-%d)
|
||||
SAFE_TITLE="${DATE_PREFIX}-${SAFE_TITLE}"
|
||||
fi
|
||||
|
||||
# Construct the filename based on format
|
||||
if [ "$SINGLE_PAGE" = true ]; then
|
||||
FILENAME="${SAFE_TITLE}.md"
|
||||
else
|
||||
FILENAME="${SAFE_TITLE}/"
|
||||
fi
|
||||
|
||||
# Construct the full path
|
||||
CONTENT_PATH="${TYPE}/${FILENAME}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue