Switched to using associative arrays instead of two regular arrays for metadata, and ensured that the site map does not contain any file without a 'date-published' line
# Loop through 'meta_key' array, search for all occurences of the values in the HTML doc, and replace them with corresponding values in 'meta_value'.
# Loop through the keys of the 'meta_array' array, search for all occurences of the key in the HTML doc, and replace them with the corresponding value..
forindex in $(seq 0`expr "${#meta_key[@]}" - 1`);do
forarr_key in "${!meta_array[@]}";do
sed -i "s/[\$][\$]${meta_key[$index]}[\$][\$]/${meta_value[index]}/g"$1
sed -i "s/[\$][\$]$arr_key[\$][\$]/${meta_array[$arr_key]}/g"$1
done
done
}
}
@ -106,12 +114,12 @@ md_to_html() {
for file in $files;do
for file in $files;do
read_metadata $file# Sets the 'metadata' variable
read_metadata $file# Sets the 'metadata' variable
convert_to_array "$metadata"#Sets the 'meta_key' and 'meta_value' arrays
convert_to_array "$metadata"#Sets the 'meta_array' array
add_date_to_array "$file"#Uses 'meta_key' and 'meta_value' arrays
add_date_to_array "$file"#Uses 'meta_array' array
# Copy file to temp dir and strip metadata
# Copy file to temp dir and strip metadata
cp $file$BASE_PATH/temp/
cp $file$BASE_PATH/temp/
letnum_lines=$(echo$metadata| wc -l)+1
letnum_lines=$(echo"$metadata"| wc -l)+1
sed -i "1,${num_lines}d"$BASE_PATH/temp/`basename $file`
sed -i "1,${num_lines}d"$BASE_PATH/temp/`basename $file`
echo"$file" >> $BASE_PATH/temp/file_listing.txt # Write files that have a date published to a temp file (we only want the files with date modified, because only these files can be listed with their date on the site map)