_pages: Again

This commit is contained in:
Stig-Ørjan Smelror 2024-02-02 17:52:25 +01:00
parent e92d09f1dd
commit 8eb0d10023

17
qsgen2
View File

@ -436,22 +436,9 @@ function _pages() {
local page_content=$(echo "$page_content" | ${engine}) local page_content=$(echo "$page_content" | ${engine})
fi fi
if [[ ${new_updated_blogs} == "true" ]] && [[ ${blog_in_index} == "true" ]]; then if (${debug}) _msg debug "_pages: Replacing BODY with page_content in pages_tpl"
if [[ ${pages_in_array} == "index.${file_ext}" ]]; then
# Insert page_content into pages_tpl by replacing the BODY tag present there
if (${debug}) _msg debug "_pages: 1. Replacing BODY with page_content in pages_tpl using Perl"
# Use Perl for multi-line and special character handling # Use Perl for multi-line and special character handling
local pages_tpl=$( awk -v new_body="$page_content" '{sub(/BODY/, new_body)} 1' <(echo "${pages_tpl}") ) local pages_tpl=$( awk -v new_body="$page_content" '{sub(/BODY/, new_body)} 1' <(echo "${pages_tpl}") )
else
if (${debug}) _msg debug "_pages: 2. Replacing BODY with page_content in pages_tpl using Perl"
# Use Perl for multi-line and special character handling
local pages_tpl=$( awk -v new_body="$page_content" '{sub(/BODY/, new_body)} 1' <(echo "${pages_tpl}") )
fi
elif [[ ${new_updated_blogs} == "false" ]] && [[ ${blog_in_index} == "false" ]]; then
if (${debug}) _msg debug "_pages: 3. Replacing BODY with page_content in pages_tpl using Perl"
# Use Perl for multi-line and special character handling
local pages_tpl=$( awk -v new_body="$page_content" '{sub(/BODY/, new_body)} 1' <(echo "${pages_tpl}") )
fi
# Replace every #pagetitle in pages_tpl # Replace every #pagetitle in pages_tpl
if (${debug}) _msg debug "_pages: Replacing #pagetitle in pages_tpl" if (${debug}) _msg debug "_pages: Replacing #pagetitle in pages_tpl"
@ -855,12 +842,12 @@ function _cleanup() {
if (${debug}) _msg debug "_cleanup: Cleaning up tags in content" if (${debug}) _msg debug "_cleanup: Cleaning up tags in content"
# Perform the cleanup # Perform the cleanup
# -e "s|BLOGINDEX\ ||g"
local cleaned_content=$(echo "${content}" | sed \ local cleaned_content=$(echo "${content}" | sed \
-e "s|¤||g" \ -e "s|¤||g" \
-e "s|#showimg\ ||g" \ -e "s|#showimg\ ||g" \
-e "s|#ytvideo\ ||g" \ -e "s|#ytvideo\ ||g" \
-e "s|#link\ ||g" \ -e "s|#link\ ||g" \
-e "s|BLOGINDEX\ ||g" \
) )
# Return the cleaned content # Return the cleaned content