Skip to content

Commit 0a21778

Browse files
committed
feat: add IndexNow ping after build for faster Bing indexing
1 parent 30692d0 commit 0a21778

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,25 @@ jobs:
5757
git commit -m "Updated content"
5858
git push origin "HEAD:$BRANCH_NAME"
5959
fi
60+
61+
- name: Ping IndexNow
62+
run: |
63+
KEY="6ff2b87724ac930114bf05c74db50bb5"
64+
HOST="weekly.tw93.fun"
65+
66+
URLS=$(git diff --name-only HEAD~1 HEAD -- 'src/pages/posts/*.md' | while read f; do
67+
slug=$(basename "$f" .md)
68+
echo "https://$HOST/posts/$slug"
69+
done)
70+
71+
if [ -z "$URLS" ]; then
72+
echo "No post URLs changed, submitting homepage"
73+
URLS="https://$HOST/"
74+
fi
75+
76+
URL_LIST=$(echo "$URLS" | jq -R -s 'split("\n") | map(select(length > 0))')
77+
echo "Submitting to IndexNow: $URL_LIST"
78+
79+
curl -s -X POST "https://api.indexnow.org/indexnow" \
80+
-H "Content-Type: application/json" \
81+
-d "{\"host\":\"$HOST\",\"key\":\"$KEY\",\"keyLocation\":\"https://$HOST/$KEY.txt\",\"urlList\":$URL_LIST}"

0 commit comments

Comments
 (0)