Skip to content

Commit

Permalink
docs: add readme to used images list
Browse files Browse the repository at this point in the history
  • Loading branch information
addetz committed Dec 11, 2024
1 parent d6ab492 commit 2f749c2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/find-unused-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e

# Create a list of all the images we have and save it to a json.
# Trim the path static/assets/docs/images.
find static/assets/docs/images -type f \( -name "*.gif" -o -name "*.webp" \) ! -name ".DS_STORE" ! -name ".DS_Store" | sed 's|static/assets/docs/images||g' > all_images.json
find static/assets/docs/images README.md -type f \( -name "*.gif" -o -name "*.webp" \) ! -name ".DS_STORE" ! -name ".DS_Store" | sed 's|static/assets/docs/images||g' > all_images.json
image_count=$(wc -l < all_images.json)
echo "Detected $image_count .webp and .gif assets in static/assets/docs/images..."

Expand All @@ -28,9 +28,10 @@ echo "$branches" > evaluated_branches.json
for current_branch in $branches; do
git checkout $current_branch

grep -Hn -E "\.webp|\.gif" README.md > readme_used_images.json
find docs -type f -name "*.md" -exec grep -Hn -E "\.webp|\.gif" {} \; > docs_used_images.json
find _partials -type f -name "*.mdx" -exec grep -Hn -E "\.webp|\.gif" {} \; > partials_used_images.json
cat docs_used_images.json partials_used_images.json > used_images.json
cat readme_used_images.json docs_used_images.json partials_used_images.json > used_images.json

line_number=1
for img in $(cat all_images.json); do
Expand All @@ -48,6 +49,7 @@ echo "Detected $unused_image_count unused webp assets in static/assets/docs/imag

# Clean up files
rm all_images.json
rm readme_used_images.json
rm docs_used_images.json
rm partials_used_images.json
rm used_images.json
Binary file added static/assets/docs/images/hide_copy_button.webp
Binary file not shown.
Binary file not shown.

0 comments on commit 2f749c2

Please sign in to comment.