_list_blogs: Rewrite

This commit is contained in:
Stig-Ørjan Smelror 2024-02-03 20:30:06 +01:00
parent 8a33d4488b
commit 65b6710edc

22
qsgen2
View File

@ -144,7 +144,7 @@ export blogdate=$( date +%a-%Y-%b-%d )
# Let's create arrays of all the files we'll be working on
function _list_pages() {
local debug=true
local debug=false
# Initialize or clear the array to ensure it's empty before adding files
pages_file_array=()
@ -172,24 +172,30 @@ function _list_pages() {
function _list_blogs() {
local debug=false
# Initialize or clear the blogs array to ensure it's empty before adding files
blogs_file_array=()
export no_blogs_found=false
# Temporarily set null_glob for this function
setopt local_options null_glob
# Check if there are any .blog files in the blog directory
local blog_files=(blog/*.blog)
if (( ${#blog_files} == 0 )); then
if (${debug}); then _msg debug "_list_blogs: No blog files found."; fi
# Directly capture matching blog files into an array
local -a blog_files=(blog/*.blog)
if (( ${#blog_files[@]} == 0 )); then
if ${debug}; then _msg debug "_list_blogs: No blog files found."; fi
export no_blogs_found=true
return
fi
for file in $( ls -har blog/*.blog ); do
else
for file in "${blog_files[@]}"; do
if ${debug}; then _msg debug "_list_blogs: Adding file to array: $file"; fi
blogs_file_array+=("$file")
done
fi
}
# BLOG CACHE
function _blog_cache() {
local debug=false