-
-
Save sskylar/1008a0ab7d7aed5b75bd6f6f402b0ea6 to your computer and use it in GitHub Desktop.
Find unused assets in Jekyll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for f in _uploads/* | |
do | |
basename=$(basename "$f") | |
escaped_name=$(echo -n "$basename" | ruby -e "require 'jekyll'; print Jekyll::URL.escape_path ARGF.read") | |
found=$(ag -lQ "$escaped_name" _site || ag -lQ "$basename" _site) | |
if [[ -z $found ]] | |
then | |
if [[ $1 == "--delete" ]] | |
then | |
echo "Deleting... $basename" | |
rm "$f" | |
else | |
echo "$basename" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Before running, build site (including drafts):
Dry run:
Delete unused uploads: