This is the script that I’ve written to publish my RSS and Blog
#!/bin/bash
# Change the user and username in your scriptBLOG=(/home/user/username.github.io/blog)MD=(/home/user/blog)blog_count=$(ls $BLOG | wc -l)md_count=$(ls $MD | wc -l)# Get the latest markdown file namelatest_md=$(ls $MD -t | sort -r | head -n 1)# file name for new blog htmlblog_name=$(find $MD -name "*" | sort -r | head -n 1 | xargs cat | head -n 1 | cut -c 3- | sed 's/ /_/g')# File count dose not matchif[[ $blog_count != $md_count ]];then i=$( ls $BLOG -t | head -n 1 | cut -d "." -f 1) j=$( ls $MD -t | head -n 1 | cut -d "." -f 1)# check if the index is unequalif[[ $i != $j ]]; then echo -e "New markdown found for the blog\nCreating HTML file for $latest_md" echo -e "Blog HTML file name will be:\t $blog_count.$blog_name.html\t and RSS feed will be updated\n"((blog_count++)) read -p "Confirm: (y/n) " response
if[[ $response =~ [yY]$ ]]; then pandoc $MD/$latest_md -t html -o $BLOG/$blog_count.$blog_name.html
echo "$blog_count.$blog_name.html file crated" mdrss update
echo "rss.xml updated"else echo "Blog post abort" exit 1fi echo "Publish Blog and RSS" read -p "Confirm: (y/n) " response
if[[ $response =~ [yY]$ ]]; then cd $WEBSITE
git add .
read -p "Enter your commit message" commit_message
git commit -m "$commit_message" git push
echo "Blog article added & RSS update successful"else echo "Blog post abort" exit 1fielseif[[ $i != $j ]]; then echo -e "The index of markdown and blog does not match\n!!!Attention needed\n\n$BLOG\n&\n$MD"else exit 0fifielseif[[ $blog_count == $md_count ]]; thenif[[ $i != $j ]]; then echo "The index of markdown and blog does not match\n!!!Attention needed"else echo "All up to date" exit 0fififi
I use mdrss which I’ve mentioned in my previous post, this is a simple golang tool to convert your markdown files into rss feed file. Here is the link
I also use md2html which convert the markdown file into unformatted html file. You can install using npm install -g markdown.
I do suggest to set alias to change directory into your blog markdown files and your website in your ~/.bashrc file
This file can be stored in the /usr/local/bin/ to make accessible from any dir.
I hope this was useful to you and find some inspiration