mirror of
https://github.com/abue-ammar/tinycast.git
synced 2026-10-02 08:14:38 +08:00
Deploy the Next.js export to Cloudflare as an assets-only Worker and serve it from the domain root, so `basePath` and `src/lib/asset.ts` both go away. The old GitHub Pages URL keeps working: `website/redirect/` is now a lone CNAME file, and a custom domain on a project site is what makes GitHub 301 `abue-ammar.github.io/tinycast/<path>` to `tinycast.dev/<path>` from its own edge — repo prefix stripped, path, query and fragment carried, no HTML parsed. Verified against a live project site before relying on it. Workers caps a single asset at 25 MiB and the 26.5 MiB tour video breaks it, so media that size moves to `website/media/`, out of the export, and is served from an R2 bucket behind cdn.tinycast.dev. Its own workflow mirrors the folder so a docs typo never re-uploads it. Every docs page inherited the root layout's `canonical: "/"`, which told Google the homepage was the real version of all 37 of them. Canonicals are per page now, with the trailing slash the host actually serves, and the sitemap matches. Drops the unmaintained macOS 15 Sequoia cask from the docs, the README, the issue templates and the release-notes tag filter.
32 lines
1.1 KiB
Bash
Executable File
32 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Mirror website/media/ into the R2 bucket behind cdn.tinycast.dev. Usage: upload-website-media.sh
|
|
set -euo pipefail
|
|
|
|
BUCKET="tinycast-cdn"
|
|
WEBSITE="$(cd "$(dirname "$0")/../website" && pwd)"
|
|
|
|
shopt -s nullglob
|
|
FILES=("$WEBSITE"/media/*)
|
|
if [ ${#FILES[@]} -eq 0 ]; then
|
|
echo "No media in $WEBSITE/media — nothing to upload."
|
|
exit 0
|
|
fi
|
|
|
|
cd "$WEBSITE"
|
|
for FILE in "${FILES[@]}"; do
|
|
NAME="$(basename "$FILE")"
|
|
# An unknown extension is a hard stop: R2 would serve it as octet-stream and the tag would break.
|
|
case "$NAME" in
|
|
*.mp4) TYPE="video/mp4" ;;
|
|
*.webm) TYPE="video/webm" ;;
|
|
*.mov) TYPE="video/quicktime" ;;
|
|
*.png) TYPE="image/png" ;;
|
|
*.jpg | *.jpeg) TYPE="image/jpeg" ;;
|
|
*) echo "::error::$NAME: add its content type to Scripts/upload-website-media.sh first."; exit 1 ;;
|
|
esac
|
|
printf '▸ %s (%s, %s)\n' "$NAME" "$TYPE" "$(du -h "$FILE" | cut -f1)"
|
|
npx wrangler r2 object put "${BUCKET}/${NAME}" --file "$FILE" --content-type "$TYPE" --remote
|
|
done
|
|
|
|
echo "✓ ${#FILES[@]} file(s) on https://cdn.tinycast.dev/"
|