_pages: I hope this one works and that it's the right place to put it

This commit is contained in:
Stig-Ørjan Smelror 2024-02-03 16:45:07 +01:00
parent caaeaf0c24
commit d74be20752

28
qsgen2
View File

@ -412,15 +412,13 @@ function _pages() {
pages_tpl=$(echo "${pages_tpl}" | perl -pe "s|#pagetitle|${page_title}|gs; s|#tagline|${site_tagline}|gs; s|#sitename|${site_name}|gs") pages_tpl=$(echo "${pages_tpl}" | perl -pe "s|#pagetitle|${page_title}|gs; s|#tagline|${site_tagline}|gs; s|#sitename|${site_name}|gs")
# Insert the blog to the front page is blog_in_index is true and the file in the array is index.file_ext # Insert the blog to the front page is blog_in_index is true and the file in the array is index.file_ext
if [[ ${pages_in_array} == "index.${file_ext}" && ${blog_in_index} == "true" ]]; then # and if index.tmp.html exist and is not empty
if [[ -f ${project_dir}/blog/index.tmp.html ]]; then if [[ ${pages_in_array} == "index.${file_ext}" && ${blog_in_index} == "true" && -s ${project_dir}/blog/index.tmp.html ]]; then
local blog_index_file=$(<${project_dir}/blog/index.tmp.html) local blog_index_file=$(<${project_dir}/blog/index.tmp.html)
else pages_tpl=$( awk -v new_blog="$blog_index_file" '{sub(/BLOGINDEX/, new_blog)} 1' <(echo "${pages_tpl}") )
_msg debug "Cannot find file ${project_dir}/blog/index.tmp.html" else
continue _msg debug "Cannot find file ${project_dir}/blog/index.tmp.html"
fi continue
pages_tpl=$( awk -v new_body="$blog_index_file" '{sub(/BLOGINDEX/, new_body)} 1' <(echo "${pages_tpl}") )
fi fi
# Replace every #tagline in pages_tpl # Replace every #tagline in pages_tpl
@ -551,16 +549,16 @@ function _blogs() {
blog_content=$(_youtube "${blog_content}") blog_content=$(_youtube "${blog_content}")
fi fi
elif [[ ${file_ext} == "md" ]]; then elif [[ ${file_ext} == "md" ]]; then
local blog_content=$(echo "$blog_content" | ${engine}) blog_content=$(echo "$blog_content" | ${engine})
fi fi
# Replace every #tagline in blog_content # Replace every #tagline in blog_content
if (${debug}) _msg debug "_blogs: Replacing tagline" if (${debug}) _msg debug "_blogs: Replacing tagline, sitename and pagetitle"
local blog_content=$( echo ${blog_content} | perl -pe "s|#tagline|${site_tagline}|gs" ) blog_content=$( echo ${blog_content} | perl -pe "s|#tagline|${site_tagline}|gs; s|#sitename|${site_name}|gs; s|#pagetitle|${page_title}|gs" )
# Replace every #sitename in blog_content # Replace every #sitename in blog_content
if (${debug}) _msg debug "_blogs: Replacing sitename" #if (${debug}) _msg debug "_blogs: Replacing sitename"
local blog_content=$( echo ${blog_content} | perl -pe "s|#sitename|${site_name}|gs" ) #local blog_content=$( echo ${blog_content} | perl -pe "s|#sitename|${site_name}|gs" )
blog_content=$(_last_updated "${blog_content}") blog_content=$(_last_updated "${blog_content}")
blog_content=$(_cleanup "${blog_content}") blog_content=$(_cleanup "${blog_content}")
@ -984,5 +982,5 @@ function _zhtml() {
# Time to run the first function # Time to run the first function
_blogs _blogs
_pages _pages
_add_blog_list_to_index # _add_blog_list_to_index
_sitemap _sitemap