hugo-owu-se/pre-build-generate.sh

18 lines
562 B
Bash
Raw Normal View History

2024-03-10 15:27:36 +00:00
#!/bin/bash
# Store file names in a Bash array
files=($(ls static/images/weebos_avif))
# Generate JavaScript code with the array
cat /dev/null > assets/js/image-array.js
2024-03-12 09:12:11 +00:00
echo '// This file is dynamically generated from pre-build script. Proceed with cautions when manually edit something!
let imgArray = [' >> assets/js/image-array.js
2024-03-10 15:27:36 +00:00
# Iterate through the file names and add them to the JavaScript array
for file in "${files[@]}"; do
echo " \"$file\", " >> assets/js/image-array.js
done
# Close the JavaScript array
echo "];" >> assets/js/image-array.js