главная|main page

состояние|status

блог|blog

файлы|files

программы|software

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTessa L. <tessa@volumetrics.io>2024-11-03 18:28:34 -0800
committerTessa L. <tessa@volumetrics.io>2024-11-03 18:28:34 -0800
commit9b79eb1b20edd318e8bbedb08a5d5a976a9b3f3a (patch)
tree686b05cafabbc6e5b3431350c08acbf75e609047
parenteaccab99d382eb08154291249ebcf7e74368bbd5 (diff)
parent7bf6e65f06b6541bc44f21a87d2dad515120db0c (diff)
Merge remote-tracking branch 'sitemap/sitemap'
-rw-r--r--bb.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/bb.sh b/bb.sh
index eb27178..6beda86 100644
--- a/bb.sh
+++ b/bb.sh
@@ -73,6 +73,8 @@ global_variables() {
# Add them as a bash array, e.g. non_blogpost_files=("news.html" "test.html")
non_blogpost_files=()
+ # site map file
+ blog_sitemap="sitemap.xml"
# feed file (rss in this case)
blog_feed="feed.rss"
number_of_feed_articles="10"
@@ -145,6 +147,8 @@ global_variables() {
date_format_full="%a, %d %b %Y %H:%M:%S %z"
date_format_timestamp="%Y%m%d%H%M.%S"
date_allposts_header="%B %Y"
+ # Data format for sitemap
+ date_format_sitemap="%Y/%m/%d"
# Perform the post title -> filename conversion
# Experts only. You may need to tune the locales too
@@ -903,6 +907,35 @@ list_posts() {
echo -e "$lines" | column -t -s "#"
}
+
+# generate sitemap
+make_sitemap() {
+ echo -n "Building Sitemap "
+ rm "$blog_sitemap"
+
+ sitemapfile=$blog_sitemap.$RANDOM
+ while [[ -f $blog_sitemap ]]; do sitemapfile=$blog_sitemap.$RANDOM; done
+
+ {
+ echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ echo "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">"
+ echo -n "." 1>&3
+ while IFS='' read -r i; do
+ echo -n "." 1>&3
+ echo "<url>"
+ echo "<loc>$global_url/${i#./}</loc>"
+ echo "<lastmod>$(LC_ALL=C date -r "$i" +"$date_format_sitemap")</lastmod>"
+ echo "</url>"
+ done < <(ls -t ./*.html)
+
+ echo "</urlset>"
+ } 3>&1 >"$sitemapfile"
+ echo ""
+
+ mv "$sitemapfile" "$blog_sitemap"
+ chmod 644 $blog_sitemap
+}
+
# Generate the feed file
make_rss() {
echo -n "Making RSS "
@@ -1205,6 +1238,7 @@ do_main() {
all_posts
all_tags
make_rss
+ make_sitemap
delete_includes
}