New function: _add_blog_list_to_index
This commit is contained in:
		
							
								
								
									
										29
									
								
								qsgen2
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								qsgen2
									
									
									
									
									
								
							@@ -435,21 +435,7 @@ function _pages() {
 | 
			
		||||
          fi
 | 
			
		||||
        elif [[ ${file_ext} == "md" ]]; then
 | 
			
		||||
            local page_content=$(echo "$page_content" | ${engine})
 | 
			
		||||
            #echo "$page_content"
 | 
			
		||||
            #exit
 | 
			
		||||
        fi
 | 
			
		||||
        #new_updated_blogs=true
 | 
			
		||||
        # Let's find the file 'index.tpl' and add the blog if blog_in_index is true
 | 
			
		||||
        if [[ ${pages_in_array} == "index.${file_ext}" ]] && [[ ${blog_in_index} == "true" ]]; then
 | 
			
		||||
            if (${debug}) _msg debug "_pages: Inserting blog list to index.html"
 | 
			
		||||
            local blog_index_list=$(<${project_dir}/blog/index.tmp.html)
 | 
			
		||||
            page_content=$( echo ${blog_index_list} >> ${page_content} )
 | 
			
		||||
        fi
 | 
			
		||||
        
 | 
			
		||||
        # Insert page_content into pages_tpl by replacing the BODY tag present there
 | 
			
		||||
        if (${debug}) _msg debug "_pages: 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}") )
 | 
			
		||||
        
 | 
			
		||||
        # Replace every #pagetitle in pages_tpl
 | 
			
		||||
        if (${debug}) _msg debug "_pages: Replacing #pagetitle in pages_tpl"
 | 
			
		||||
@@ -679,6 +665,20 @@ function _blog_index() {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function _add_blog_list_to_index() {
 | 
			
		||||
  
 | 
			
		||||
  local debug=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 (${debug}) _msg debug "_pages: Inserting blog list to index.html"
 | 
			
		||||
    local blog_index_list=$(<${project_dir}/blog/index.tmp.html)
 | 
			
		||||
    local site_index_file=$(<${www_root}/index.tmp.html)
 | 
			
		||||
    awk -v new_body="$site_index_file" '{sub(/BLOGINDEX/, new_body)} 1' <(echo "${blog_index_list}")
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function _sitemap() {
 | 
			
		||||
    
 | 
			
		||||
# Check if sitemap is set to true and if there are updated Blogs or Pages before updating the sitemap.xml file.
 | 
			
		||||
@@ -900,4 +900,5 @@ _html() {
 | 
			
		||||
# Time to test the first function
 | 
			
		||||
_blogs
 | 
			
		||||
_pages
 | 
			
		||||
_add_blog_list_to_index
 | 
			
		||||
_sitemap
 | 
			
		||||
		Reference in New Issue
	
	Block a user