This is probably the 8th time I restart my blog. After using hexo,Beex (which is dead by now) and tons of other SSAs. I still don't feel okay. I want a environment with no distraction, but end up these things have tons of them. After some expriment and trials, I eventually find a way to write what I want to write calmly. This blog structure only contains a .sh file. I even wrote it with AI.
#!/bin/bash
# ==========================================
# PART 1: Create the new Blog Post
# ==========================================
# Check if a filename argument was provided
if [ -z "$1" ]; then
echo "Usage: $0 \"filename or title\""
exit 1
fi
# Get the input filename/title
input_name="$1"
# Replace all spaces with underscores
sanitized_name=$(echo "$input_name" | tr ' ' '_')
# Ensure the file ends with .html
case "$sanitized_name" in
*.html)
# Filename already ends with .html
;;
*)
sanitized_name="${sanitized_name}.html"
;;
esac
# Ensure directory exists
mkdir -p ./yappings
# Create the file with the basic HTML template
cat < "./yappings/$sanitized_name"
whatever you want
EOF
# Append to list.txt (using || as separator)
# Note: This creates "filename||date"
echo "${sanitized_name}||$(date +%F)\n" >> ./yappings/list.txt
echo "Successfully created blog post: ./yappings/$sanitized_name"
# ==========================================
# PART 2: Re-generate the Archive List
# ==========================================
echo "Updating archive.html..."
# Define input and output files
INPUT_FILE="./yappings/list.txt"
OUTPUT_FILE="archive.html"
# Write HTML header to archive.html (overwriting previous version)
cat > "$OUTPUT_FILE" << EOF
whatever you want
EOF
# Process each line of the input file
if [ -f "$INPUT_FILE" ]; then
while IFS= read -r line || [ -n "$line" ]; do
# Skip empty lines
[ -z "$line" ] && continue
# Parse fields based on || separator
# Field 1: filename
# Field 3: date (because || creates an empty Field 2)
filename=$(echo "$line" | cut -d'|' -f1 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
createdate=$(echo "$line" | cut -d'|' -f3 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
# Remove any leading | from creation date if present (failsafe)
createdate=$(echo "$createdate" | sed 's/^|//')
# Create display name by replacing underscores with spaces
display_name=$(echo "$filename" | sed 's/_/ /g')
# Write table row to HTML
cat >> "$OUTPUT_FILE" << EOF
whatever you want
EOF
done < "$INPUT_FILE"
else
echo "Warning: $INPUT_FILE not found."
fi
# Write HTML footer
cat >> "$OUTPUT_FILE" << EOF
whatever you want
EOF
echo "Archive updated: $OUTPUT_FILE"
Yeah that's it, that's the whole blog system, all within 100 lines of code if you don't count the template
You can conveniently adjust whatever you want, you can write in HTML, do whatever you want is ok.
But if you wanna do nothing? simply start writing with plain html.
Of course you may add markdown or something (which I probably will do later on), but that's an html thing.