diff --git a/qsgen2 b/qsgen2 index 868a0fc..ae1eadc 100755 --- a/qsgen2 +++ b/qsgen2 @@ -942,16 +942,14 @@ function _sitemap() { # Find all HTML files and store them in an array # local -a html_files=("${(@f)$(find "${www_root}" -type f -name "*.html")}") builtin cd ${config[site_root]} - local -a html_files=(**/[a-z]*.html(.)) - local -a blog_files=(${html_files[@]:#*blog*}) + local -a blog_files=() local -a page_files=() for file in "${html_files[@]}"; do - [[ $file != *blog* ]] && page_files+=("$file") - done - - local -a xml_files=([a-z]*.xml(.)) - for file in "${xml_files[@]}"; do - [[ $file != *sitemap.* ]] && xml_files+=("$file") + if [[ $file == *blog* ]]; then + blog_files+=("$file") + else + page_files+=("$file") + fi done # Start of the XML file for BLOGS @@ -1012,38 +1010,32 @@ function _sitemap() { echo '' >> "${sitemap_page}" _msg std " - ${p_file}" - # Start of the XML file - echo '' > ${sitemap_file} - echo "" >> ${sitemap_file} - echo "" >> ${sitemap_file} - echo '> ${sitemap_file} - echo ' xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"' >> ${sitemap_file} - echo ' xmlns:xhtml="http://www.w3.org/1999/xhtml"' >> ${sitemap_file} - echo ' xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"' >> ${sitemap_file} - echo '>' >> ${sitemap_file} - - # Add each URL to the sitemap - for file in "${xml_files[@]}" - do - # Remove www_root from the path and prepend site_url - local url="${site_url}/${file#$www_root}" - local lastmod=$(stat -c %y "${file}" 2>/dev/null | cut -d' ' -f1,2 | sed 's/ /T/' | sed 's/\..*$//') - - echo " " >> ${sitemap_file} - echo " ${url}" >> ${sitemap_file} - echo " " >> "${sitemap_file}" - echo " " >> ${sitemap_file} - echo " " >> ${sitemap_file} - echo " " >> ${sitemap_file} - done - - # End of the XML file - echo '' >> "${sitemap_file}" - _msg std " - ${sm_file}" - if (${debug}); then _msg debug "${0:t}_msg_2" " ${sitemap_file}"; fi fi + + # Start of the XML file for the main sitemap + echo '' > "${sitemap_file}" + echo "" >> "${sitemap_file}" + + # Add sitemap-blogs.xml to the sitemap + echo " " >> "${sitemap_file}" + echo " ${site_url}/${b_file}" >> "${sitemap_file}" + local lastmod_b=$(stat -c %y "${b_file}" 2>/dev/null | cut -d' ' -f1,2 | sed 's/ /T/' | sed 's/\..*$//') + echo " ${lastmod_b}" >> "${sitemap_file}" + echo " " >> "${sitemap_file}" + + # Add sitemap-pages.xml to the sitemap + echo " " >> "${sitemap_file}" + echo " ${site_url}/${p_file}" >> "${sitemap_file}" + local lastmod_p=$(stat -c %y "${p_file}" 2>/dev/null | cut -d' ' -f1,2 | sed 's/ /T/' | sed 's/\..*$//') + echo " ${lastmod_p}" >> "${sitemap_file}" + echo " " >> "${sitemap_file}" + + # End of the XML file + echo "" >> "${sitemap_file}" + _msg std " - ${sm_file}" + builtin cd ${config[project_root]} }