From ddb3af1f46f0b91c2acf2bc2ee40d9cb4b6ea979 Mon Sep 17 00:00:00 2001
From: Gal <mail@velouria.dev>
Date: Sat, 2 Mar 2024 09:15:33 +0100
Subject: [PATCH] :sparkles: Unpublish posts

---
 scripts/publish.sh | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/scripts/publish.sh b/scripts/publish.sh
index 5df80f5..2a00c0a 100755
--- a/scripts/publish.sh
+++ b/scripts/publish.sh
@@ -82,6 +82,24 @@ find -L "$SOURCE_DIR" -type f -name "*.md" -exec grep -q "publish: true" {} \; -
     fi
 done
 
+# Find Markdown files with "publish: false" and process them
+find -L "$SOURCE_DIR" -type f -name "*.md" -exec grep -q "publish: false" {} \; -exec grep -l "publish: false" {} + | while read -r markdown_file; do
+    # Extract relative path from the source directory
+    relative_path="${markdown_file#$SOURCE_DIR/}"
+
+    # Destination path
+    dest_path="$DEST_DIR/$relative_path"
+
+    # Check if the destination file exists
+    if [ -f "$dest_path" ]; then
+        # Remove the file from DEST_DIR
+        rm "$dest_path"
+        echo "Removed $markdown_file from $DEST_DIR" >> "$LOG_FILE"
+    else
+        echo "File $markdown_file not found in $DEST_DIR" >> "$LOG_FILE"
+    fi
+done
+
 # Print the log file
 cat "$LOG_FILE"