diff --git a/build.sh b/build.sh index 21b9ffd..59e758c 100755 --- a/build.sh +++ b/build.sh @@ -233,6 +233,42 @@ gen_sorted_file_list() { # Generate a list of the HTMl files, sorted by when the sorted_file_list=$(echo "$sorted_file_list" | awk '{print $1}') # Store only the first column (the file path) in the variable } +gen_rss_feed() { # Uses the sorted_file_list variable to generate an RSS feed + echo "Generating RSS Feed..." + local RSS_FEED_PATH="${BASE_PATH}/output/rss.xml" + touch "RSS_FEED_PATH" # Create the RSS file + local RSS_CONTENT="\n" + counter=0 + RSS_CONTENT+="\n" + RSS_CONTENT+="Two More Cents\n" + RSS_CONTENT+="http://twomorecents.org/\n" + RSS_CONTENT+="The personal website of Aadhavan Srinivasan.\n" + RSS_CONTENT+="en-us\n" + RSS_CONTENT+="$(date -R)\n" + RSS_CONTENT+="s4g - Stupid Simple Static Site Generator\n" + + for file in $1; do + if [ $counter -gt 9 ]; then + break + fi + RSS_CONTENT+="\n" + RSS_CONTENT+="\n" + RSS_CONTENT+=$(cat "$file" | grep "<title>" | head -n 1 | awk -F'[<>]' '{print $3}')$'\n' + RSS_CONTENT+="\n" + RSS_CONTENT+="\n" + RSS_CONTENT+="https://twomorecents.org/" + RSS_CONTENT+=$(realpath --relative-to="${BASE_PATH}/output" "$file") + RSS_CONTENT+="\n" + RSS_CONTENT+="\n" + ((++counter)) + done + + RSS_CONTENT+="\n" + + echo -e "$RSS_CONTENT" > $RSS_FEED_PATH + +} + gen_index_page() { # Generate an index page (site map) that includes links to the other pages echo "Generating index page..." @@ -285,6 +321,7 @@ setup_output_dir del_files_in_output md_to_html gen_sorted_file_list # Sets the 'sorted_file_list' variable +gen_rss_feed "$sorted_file_list" # Uses the 'sorted_file_list' variable gen_index_page "$sorted_file_list" # Uses the 'sorted_file_list' variable copy_things_in clean_up