Working on _blog_idx_for_index

This commit is contained in:
Stig-Ørjan Smelror 2024-01-30 12:24:46 +01:00
parent 3c05cbd730
commit c1a2dc1c69

52
qsgen2
View File

@ -439,6 +439,8 @@ function _blogs() {
blog_url="${blog_dir}/${blog_index}.html" blog_url="${blog_dir}/${blog_index}.html"
if (${debug}) echo "_blogs: Processing ${blog}" if (${debug}) echo "_blogs: Processing ${blog}"
echo "${green}Generating blog ${blog_index}.html${end}"
# Prepare the blog template # Prepare the blog template
if (${debug}) echo "_blogs: Processing substitutes in ${blog}" if (${debug}) echo "_blogs: Processing substitutes in ${blog}"
@ -485,12 +487,22 @@ function _blogs() {
else else
# Export metadata mode # Declare the array to hold metadata strings for each blog
if (${debug}) echo "_blogs: Exporting metadata for ${blog}" declare -a BLOG_META_STR_ARRAY
export BLOG_SDATE="${sdate[@]}"
export BLOG_BTITLE="${btitle}" # Iterate over make_blog_array
export BLOG_INGRESS="${ingress}" for blog in "${make_blog_array[@]}"; do
export BLOG_URL="${www_root}${blog_url}" if ${debug}; then echo "_blogs: Adding data for ${blog} to array"; fi
# Concatenate all metadata into a single string for the current blog
local metadata_str="SDATE: ${sdate[*]}||BTITLE: ${btitle}||INGRESS: ${ingress}||URL: ${www_root}${blog_url}"
# Append this metadata string to the array
BLOG_META_STR_ARRAY+=("${metadata_str}")
done
# Now BLOG_META_STR_ARRAY contains the metadata string for each blog post
export BLOG_META_STR_ARRAY
fi fi
@ -502,12 +514,19 @@ function _blogs() {
function _blog_idx_for_index() { function _blog_idx_for_index() {
# This function generates the file blog/index.idx # This function generates the file blog/index.idx
local debug=false # We use _blogs to get the data to create the blog index
_blogs get_index
if [[ -f ${project_dir}/blog/index.tmp.html ]]; then local debug=false
echo "Remove temporary file: ${project_dir}/blog/index.tmp.html" local blog_list=$(<${project_dir}/templates/${theme}/blog_list.tpl)
rm -f ${project_dir}/blog/index.tmp.html
fi for blogs in ${BLOG_META_STR_ARRAY[@]}
do
echo ${blogs[URL]}
echo ${blogs[BTITLE]}
echo ${blogs[SDATE[@]]}
echo ${blogs[INGRESS]}
done
} }
@ -739,7 +758,10 @@ function _html() {
} }
# Time to test the first function # Time to test the first function
echo "${green}Running function _blogs${end}" #echo "${green}Running function _blogs${end}"
_blogs #_blogs
echo "${green}Running function _pages${end}" #echo "${green}Running function _pages${end}"
_pages #_pages
echo "Running _blog_idx_for_index"
_blog_idx_for_index