New function: _list_pages. Prepared to use Markdown as Pages.

This commit is contained in:
Stig-Ørjan Smelror 2024-02-01 17:48:59 +01:00
parent cfec40e5bb
commit 2e74d5f5d6

27
qsgen2
View File

@ -145,6 +145,7 @@ fi
if [[ ${generator} == "native" ]]; then
# Usage: ${engine} ${1} - Where 1 is the file you want to convert
engine=_html
file_ext=tpl
elif [[ ${generator} == "markdown" ]]; then
if [[ ! -f /usr/bin/markdown ]]; then
_msg other "Please install the 'discount' package to use Markdown."
@ -152,6 +153,7 @@ elif [[ ${generator} == "markdown" ]]; then
else
# Usage: ${engine} ${1} - Where 1 is the file you want parsed
engine=$( /usr/bin/markdown ${1} -d )
file_ext=md
fi
fi
if (${debug}) _msg debug "Using the ${generator} engine"
@ -168,6 +170,27 @@ 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=false
export no_pages_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 pages_files=(*.${file_ext})
if (( ${#pages_files} == 0 )); then
if (${debug}); then _msg debug "_list_pages: No Pages found."; fi
export no_pages_found=true
return
fi
for file in $( ls *.${file_ext} ); do
pages_file_array+=("$file")
done
}
function _list_blogs() {
local debug=false
@ -255,8 +278,10 @@ function _pages_cache() {
# Initialize the array for storing pages files to process
pages_array=()
_list_pages
# Process pages files
for file in $(ls -1bt *tpl); do
for file in ${pages_file_array[@]}; do
# Compute the current blog file hash
current_hash=$(md5sum "$file" | awk '{print $1}')