revamp projects, continue editing and add precommit hook for lastmod frontmatter

This commit is contained in:
2026-02-02 23:13:56 -07:00
parent 23a44c1e4f
commit 2fad7c173b
16 changed files with 357 additions and 47 deletions
+6
View File
@@ -5,6 +5,12 @@ NC='\033[0m' # No Color
echo "Running pre-commit checks..."
# Auto-update lastmod in content files (non-blocking)
# Runs before other checks so lint/spell run on updated files
if [ -x "$(dirname "$0")/update-lastmod.sh" ]; then
"$(dirname "$0")/update-lastmod.sh" || echo "⚠️ lastmod update script encountered an issue"
fi
# Track overall success/failure
OVERALL_RESULT=0
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Auto-update lastmod field in staged content files
# This script should never block a commit - errors are warnings only
update_lastmod() {
local file="$1"
# Generate RFC3339 timestamp with timezone (e.g., 2025-11-08T16:19:07-06:00)
local tz_offset=$(date +%z)
local tz_formatted="${tz_offset:0:3}:${tz_offset:3:2}" # Insert colon: -0600 -> -06:00
local now=$(date +%Y-%m-%dT%H:%M:%S)${tz_formatted}
# Only update if file has lastmod field
if grep -q "^lastmod:" "$file"; then
# Cross-platform sed -i (macOS vs Linux)
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/^lastmod:.*$/lastmod: $now/" "$file"
else
sed -i "s/^lastmod:.*$/lastmod: $now/" "$file"
fi
git add "$file"
echo " Updated lastmod in $file"
fi
}
# Get staged content files
staged_files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '^content/.*\.md$' || true)
if [ -z "$staged_files" ]; then
exit 0
fi
for file in $staged_files; do
if [ -f "$file" ]; then
update_lastmod "$file" || echo "Warning: Failed to update lastmod in $file"
fi
done