Skip to content

Commit 9f87053

Browse files
committed
Do not add footer.js to files not in Git
It makes no sense to link to the view source on GitHub if the file itself e.g. colophon or by-month is not in Git. https://gistpreview.github.io/?580ac41843d2165907ac14a3cf07eb20
1 parent 28402aa commit 9f87053

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ FOOTER_HASH=$(git log -1 --format="%H" -- footer.js)
3232
FOOTER_SHORT_HASH=$(echo "$FOOTER_HASH" | cut -c1-8)
3333

3434
# Insert footer.js script tag into all root-level .html files except index.html
35+
# Only process files that are tracked in git
3536
for file in *.html; do
36-
if [ -f "$file" ] && [ "$file" != "index.html" ]; then
37+
if [ -f "$file" ] && [ "$file" != "index.html" ] && git ls-files --error-unmatch "$file" > /dev/null 2>&1; then
3738
# Check if footer.js is not already included
3839
if ! grep -q 'src="footer.js' "$file"; then
3940
# Insert script tag before the LAST </body> tag using awk

0 commit comments

Comments
 (0)