Skip to content

Commit

Permalink
Add Cloudflare analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
ayaka14732 committed Dec 2, 2024
1 parent b7ebb33 commit 3d941e2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ jobs:
- name: Test
run: npm test
- name: Build documentation
run: npm run doc:html
run: |
npm run doc:html
./inject_cf_analytics.sh
4 changes: 3 additions & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ jobs:
- name: Build
run: npm run build
- name: Build documentation
run: npm run doc:html
run: |
npm run doc:html
./inject_cf_analytics.sh
- name: Publish
run: |
# Create a temporary directory
Expand Down
8 changes: 8 additions & 0 deletions inject_cf_analytics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

TARGET_DIR="./docs"
SCRIPT="<script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{\"token\": \"16ad6c356b37426cb31816318ed5a42d\"}'></script>"

find "$TARGET_DIR" -type f -name "*.html" | while read -r FILE; do
sed -i "s|</head>|$SCRIPT</head>|g" "$FILE"
done

0 comments on commit 3d941e2

Please sign in to comment.