commit ea500adc9fbd8b4ecc7db800a01934ebc11a7544
parent 1e4a64804b5e51dac4a44290ca483f56638da67f
Author: Francesco Saccone <francesco@francescosaccone.com>
Date: Sun, 9 Mar 2025 17:24:13 +0100
feat: do not use dates in atom.xml and sitemap.xml
When using the scripts in my server, the generated dates were all
"1970-01-01 00:00:01". I have no idea why it happened, but I could
not figure out how to fix it, so I now think dates are just
unnecessary and move on.
Signed-off-by: Francesco Saccone <francesco@francescosaccone.com>
Diffstat:
2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/scripts/generate-atom.sh b/scripts/generate-atom.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-for program in date dirname echo find mkdir realpath sed; do
+for program in dirname echo find mkdir realpath sed; do
if ! command -v "$program" > /dev/null 2>&1; then
echo "Error: Required program '$program' is not installed."
exit 1
@@ -21,14 +21,11 @@ BASE_URL="$3"
mkdir -p "$DESTINATION"
-BLOG_LAST_MODIFIED=$(date -ur "$BLOG_SOURCE" +"%Y-%m-%dT%H:%M:%SZ")
-
{
echo -n "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
echo -n "<feed xmlns=\"http://www.w3.org/2005/Atom\">"
echo -n "<title>${TITLE}</title>"
echo -n "<link href=\"${BASE_URL}\" rel=\"self\"/>"
- echo -n "<updated>$BLOG_LAST_MODIFIED</updated>"
echo -n "<id>$BASE_URL/atom.xml</id>"
} > "$ATOM_FILE"
@@ -44,14 +41,11 @@ in $(find "$BLOG_SOURCE" -mindepth 2 -maxdepth 2 -type f -name "index.md"); do
# First capitalise the first letter, then replace hyphens with spaces.
entry_title=$(echo "${entry_title_id^}" | sed -e 's/-/ /g')
-
- last_modified=$(date -ur "$md_file" +"%Y-%m-%dT%H:%M:%SZ")
{
echo -n "<entry>"
echo -n "<title>$entry_title</title>"
echo -n "<link href=\"$url\"/>"
- echo -n "<updated>$last_modified</updated>"
echo -n "</entry>"
} >> "$ATOM_FILE"
done
diff --git a/scripts/generate-sitemap.sh b/scripts/generate-sitemap.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-for program in date dirname echo find mkdir realpath; do
+for program in dirname echo find mkdir realpath; do
if ! command -v "$program" > /dev/null 2>&1; then
echo "Error: Required program '$program' is not installed."
exit 1
@@ -28,12 +28,10 @@ for md_file in $(find "$SOURCE" -type f -name "index.md"); do
md_relative_file="${md_file#$SOURCE/}"
url="$BASE_URL/$(dirname $md_relative_file)"
- last_modified=$(date -ur "$md_file" +"%Y-%m-%dT%H:%M:%SZ")
{
echo -n "<url>"
echo -n "<loc>$url</loc>"
- echo -n "<lastmod>$last_modified</lastmod>"
echo -n "</url>"
} >> "$SITEMAP_FILE"
done