diff --git a/qsgen2 b/qsgen2 index c19dadc..d50fd5a 100755 --- a/qsgen2 +++ b/qsgen2 @@ -620,7 +620,7 @@ function _blogs() { local debug=true else # If you want to debug this function only, set this to true - local debug=false + local debug=true fi # Running function _list_blogs @@ -668,10 +668,12 @@ function _blogs() { do # Check for the DATE line if [[ "${line}" == "DATE "* ]]; then + if (${debug}) _msg debug "_blogs: Looking for DATE: Found" date_found=true fi # Check for the BLOG_TITLE line if [[ "${line}" == "BLOG_TITLE "* ]]; then + if (${debug}) _msg debug "_blogs: Looking for BLOG_TITLE: Found" title_found=true fi # If both DATE and BLOG_TITLE are found, no need to continue checking @@ -682,17 +684,16 @@ function _blogs() { # Check if DATE or BLOG_TITLE metadata is missing and log message if [[ "${date_found}" == false ]]; then - _msg debug "_blogs: DATE metadata missing in ${blog}." + _msg debug "* _blogs: DATE metadata missing in ${blog}." continue # Skip this file and move to the next fi - if [[ "${title_found}" == false ]]; then - _msg debug "_blogs: BLOG_TITLE metadata missing in ${blog}." + _msg debug "* _blogs: BLOG_TITLE metadata missing in ${blog}." continue # Skip this file and move to the next fi # Extract blog information - sed -i "s/GETDATE/${blogdate}/" ${blog} + # sed -i "s/GETDATE/${blogdate}/" ${blog} # Array sdate = Name day=1, Year=2, Month=3, Number day=4 sdate=( $( echo ${content} | grep DATE | sed "s|DATE\ ||" | sed "s|\-|\ |g" ) ) if [[ ${generator} == "native" ]]; then @@ -703,16 +704,14 @@ function _blogs() { fi done <<< "$content" elif [[ ${generator} == "markdown" ]]; then - local b_title="" while IFS= read -r line; do if [[ "$line" == \#* ]]; then - b_title="${line#\#}" # Remove the first '#' character - b_title="${b_title#\#}" # Remove the second '#' character if present - b_title="${b_title#"${b_title%%[![:space:]]*}"}" # Trim leading whitespace + btitle="${line#\#}" # Remove the first '#' character + btitle="${btitle#\#}" # Remove the second '#' character if present + btitle="${btitle#"${btitle%%[![:space:]]*}"}" # Trim leading whitespace break # Exit the loop after finding the first heading fi done <<< "$content" - btitle=${b_title} fi ingress=$( echo ${content} | sed "s/'/\\\'/g" | xargs | grep -Po "#INGRESS_START\K(.*?)#INGRESS_STOP" | sed "s|\ \#INGRESS_STOP||" | sed "s|^\ ||" ) body=$( echo ${content} | sed "s/'/\\\'/g" | xargs | grep -Po "#BODY_START\K(.*?)#BODY_STOP" | sed "s|\ \#BODY_STOP||" | sed "s|^\ ||" )