_pages: Trying to get blog index written to main index if set

This commit is contained in:
Stig-Ørjan Smelror 2024-02-02 17:10:48 +01:00
parent 93dfc039e7
commit 8e99cc479a

18
qsgen2
View File

@ -436,10 +436,18 @@ function _pages() {
local page_content=$(echo "$page_content" | ${engine}) local page_content=$(echo "$page_content" | ${engine})
fi fi
# Insert page_content into pages_tpl by replacing the BODY tag present there if [[ ${new_updated_blogs} == "true" ]] && [[ ${blog_in_index} == "true" ]]; then
if (${debug}) _msg debug "_pages: Replacing BODY with page_content in pages_tpl using Perl" if [[ ${pages_in_array} == "index.${file_ext}" ]]; then
# Use Perl for multi-line and special character handling # Insert page_content into pages_tpl by replacing the BODY tag present there
local pages_tpl=$( awk -v new_body="$page_content" '{sub(/BODY/, new_body)} 1' <(echo "${pages_tpl}") ) 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
local pages_tpl=$( awk -v new_body="$page_content" '{sub(/BODY/, new_body)} 1' <(echo "${pages_tpl}") )
fi
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
# 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"
@ -681,7 +689,7 @@ function _add_blog_list_to_index() {
# Let's find the file 'index.tpl' and add the blog if blog_in_index is true # Let's find the file 'index.tpl' and add the blog if blog_in_index is true
if [[ ${new_updated_blogs} == "true" ]] && [[ ${blog_in_index} == "true" ]]; then if [[ ${new_updated_blogs} == "true" ]] && [[ ${blog_in_index} == "true" ]]; then
if (${debug}) _msg debug "_pages: Inserting blog list to index.html" if (${debug}) _msg debug "_add_blog_list_to_index: Inserting blog list to index.html"
local blog_index_list=$(<${project_dir}/blog/index.tmp.html) local blog_index_list=$(<${project_dir}/blog/index.tmp.html)
local site_index_file=$(<${www_root}/index.html) local site_index_file=$(<${www_root}/index.html)
echo "${site_index_file}" | awk -v new_body="${blog_index_list}" '{sub(/BLOGINDEX/, new_body)} 1' > "${www_root}/index.html" echo "${site_index_file}" | awk -v new_body="${blog_index_list}" '{sub(/BLOGINDEX/, new_body)} 1' > "${www_root}/index.html"