Unpublish posts

This commit is contained in:
Gal 2024-03-02 09:15:33 +01:00
parent 3e162637f5
commit ddb3af1f46
Signed by: gal
GPG Key ID: F035BC65003BC00B
1 changed files with 18 additions and 0 deletions

View File

@ -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"