Add an rss feed to the blg.

This commit is contained in:
James Chip 2024-01-09 07:14:35 +00:00
parent 9bda8272f1
commit 4bb9483c44
1 changed files with 69 additions and 24 deletions

View File

@ -2,6 +2,12 @@ function blg
set -g blog_title "This is the blog title"
set -g blog_index "tmp/index.gmi"
# These variables are used to generate the RSS feed, youshould edit them to your needs
set -g rss_domain "http://your_webs.site"
set -g rss_title "name of news feed"
set -g rss_desc "description of news feed"
set -g rss_index "index.xml"
argparse 'n/new-post' 'i/init' -- $argv
@ -80,7 +86,9 @@ function build_blog
rm -rf tmp
end
mkdir tmp
start_rss
while read -l line
switch $line
case "#*"
@ -110,10 +118,16 @@ function build_blog
end
write_file "$article_title" "$article_title" "$tag_tags" "$article_file" "$article_body"
add_rss_item "$article_date" "$article_title" "$article_body" "$rss_domain/$article_number.html"
echo $article_link >> $blog_index
end
end < blogmap
end_rss
cp $rss_index out/
echo "Generating index."
set -l idxbdy (cat $blog_index)
@ -252,29 +266,60 @@ end
function create_template
set template "template.html"
set template "template.html"
touch $template
touch $template
echo "<!doctype htmml>" >> $template
echo "<html>" >> $template
echo "<head>" >> $template
echo "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">" >> $template
echo "<title>;;title</title>" >> $template
echo "<meta name=\"description\" content=\";;description\">" >> $template
echo "</head>" >> $template
echo "<body id=\"top\">" >> $template
echo " <nav>" >> $template
echo " <a href=\"index.html\">index</a>" >> $template
echo " </nav>" >> $template
echo " <hr>" >> $template
echo " <main>" >> $template
echo " <h1>;;title</h1>" >> $template
echo " ;;body" >> $template
echo " </main>" >> $template
echo " <p>;;tags</p>" >> $template
echo " <p><a href=\"#top\">[top]</a></p>" >> $template
echo "</body>" >> $template
echo "</html>" >> $template
echo "<!doctype htmml>" >> $template
echo "<html>" >> $template
echo "<head>" >> $template
echo "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">" >> $template
echo "<title>;;title</title>" >> $template
echo "<meta name=\"description\" content=\";;description\">" >> $template
echo "</head>" >> $template
echo "<body id=\"top\">" >> $template
echo " <nav>" >> $template
echo " <a href=\"index.html\">index</a>" >> $template
echo " </nav>" >> $template
echo " <hr>" >> $template
echo " <main>" >> $template
echo " <h1>;;title</h1>" >> $template
echo " ;;body" >> $template
echo " </main>" >> $template
echo " <p>;;tags</p>" >> $template
echo " <p><a href=\"#top\">[top]</a></p>" >> $template
echo "</body>" >> $template
echo "</html>" >> $template
end
function start_rss
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" > $rss_index
echo "<rss version="2.0">" >> $rss_index
echo "<channel>" >> $rss_index
echo "<title>$rss_title</title>" >> $rss_index
echo "<link>$rss_domain</link>" >> $rss_index
echo "<description>$rss_desc</description>" >> $rss_index
end
function add_rss_item -a date title desc link
echo " <item>" >> $rss_index
echo " <title>$title</title>" >> $rss_index
echo " <link>$link</link>" >> $rss_index
echo " <pubDate>$date</pubDate>" >> $rss_index
echo " <description>$desc</description>" >> $rss_index
echo " </item>" >> $rss_index
end
function end_rss
echo "</channel>" >> $rss_index
echo "</rss>" >> $rss_index
end