av: clone broadcastbeat sources + AV Beat rebrand (Phase 1)
- Replaces the prior Rocket scaffold (saved on pre-bb-clone-rollback branch) - Domain: broadcastbeat.com -> avbeat.com - Brand: Broadcast Beat -> AV Beat - Slug: broadcastbeat -> avbeat (package, identifiers) - Schema fallback: bb -> av (env var name unchanged) - Placeholder AV BEAT logo (gold->red gradient) at /assets/logos/av.svg - All BB/RMP logo references repointed Outstanding before public DNS swap: - Supabase av schema bootstrap (mirror of bb tables) - WordPress archive import (avbeat-com -> av.articles) - Coolify env vars - dev-avbeat.onsethost.com staging deploy + visual review
This commit is contained in:
@@ -3,22 +3,22 @@ import map from "./legacy-image-map.json";
|
||||
const LEGACY_MAP = map as Record<string, string>;
|
||||
|
||||
const LEGACY_HOSTS = [
|
||||
"https://www.broadcastbeat.com",
|
||||
"https://broadcastbeat.com",
|
||||
"http://www.broadcastbeat.com",
|
||||
"http://broadcastbeat.com",
|
||||
"https://www.avbeat.com",
|
||||
"https://avbeat.com",
|
||||
"http://www.avbeat.com",
|
||||
"http://avbeat.com",
|
||||
];
|
||||
|
||||
export function rewriteLegacyImageUrl(url: string | null | undefined): string {
|
||||
if (!url) return "";
|
||||
// Direct map hit (canonical https://www.broadcastbeat.com/...)
|
||||
// Direct map hit (canonical https://www.avbeat.com/...)
|
||||
const direct = LEGACY_MAP[url];
|
||||
if (direct) return direct;
|
||||
// Try alternate-host normalization
|
||||
for (const host of LEGACY_HOSTS) {
|
||||
if (url.startsWith(host)) {
|
||||
const path = url.slice(host.length);
|
||||
const canonical = `https://www.broadcastbeat.com${path}`;
|
||||
const canonical = `https://www.avbeat.com${path}`;
|
||||
const hit = LEGACY_MAP[canonical];
|
||||
if (hit) return hit;
|
||||
}
|
||||
@@ -28,7 +28,7 @@ export function rewriteLegacyImageUrl(url: string | null | undefined): string {
|
||||
|
||||
export function rewriteLegacyImageUrlsInHtml(html: string): string {
|
||||
let out = html.replace(
|
||||
/(https?:\/\/(?:www\.)?broadcastbeat\.com\/wp-content\/uploads\/[^"'\s)]+)/g,
|
||||
/(https?:\/\/(?:www\.)?avbeat\.com\/wp-content\/uploads\/[^"'\s)]+)/g,
|
||||
(m) => rewriteLegacyImageUrl(m),
|
||||
);
|
||||
// Rewrite raw Supabase Storage URLs to clean first-party /img/<bucket>/<path>
|
||||
@@ -51,21 +51,21 @@ export function stripDeadLegacyImages(html: string): string {
|
||||
if (!html) return html;
|
||||
|
||||
// Match <img> tags whose src still hits the dead WP host.
|
||||
const DEAD_HOST_RE = /https?:\/\/(?:www\.)?broadcastbeat\.com\/wp-content\/uploads\//i;
|
||||
const DEAD_HOST_RE = /https?:\/\/(?:www\.)?avbeat\.com\/wp-content\/uploads\//i;
|
||||
|
||||
// Drop entire <figure>...</figure> blocks whose only inner content is a
|
||||
// dead-image <img>. Preserves figures that wrap working images.
|
||||
let out = html.replace(/<figure\b[^>]*>([\s\S]*?)<\/figure>/gi, (full, inner) => {
|
||||
if (!/<img\b[^>]*\bsrc\s*=\s*["'][^"']*broadcastbeat\.com\/wp-content\/uploads\/[^"']*["']/i.test(inner)) return full;
|
||||
if (!/<img\b[^>]*\bsrc\s*=\s*["'][^"']*avbeat\.com\/wp-content\/uploads\/[^"']*["']/i.test(inner)) return full;
|
||||
// figure contains a dead image — drop entirely
|
||||
return "";
|
||||
});
|
||||
|
||||
// Drop <a>…<img dead …>…</a> wrappers
|
||||
out = out.replace(/<a\b[^>]*>\s*<img\b[^>]*\bsrc\s*=\s*["'][^"']*broadcastbeat\.com\/wp-content\/uploads\/[^"']*["'][^>]*\/?>\s*<\/a>/gi, "");
|
||||
out = out.replace(/<a\b[^>]*>\s*<img\b[^>]*\bsrc\s*=\s*["'][^"']*avbeat\.com\/wp-content\/uploads\/[^"']*["'][^>]*\/?>\s*<\/a>/gi, "");
|
||||
|
||||
// Drop bare <img dead …>
|
||||
out = out.replace(/<img\b[^>]*\bsrc\s*=\s*["'][^"']*broadcastbeat\.com\/wp-content\/uploads\/[^"']*["'][^>]*\/?>/gi, "");
|
||||
out = out.replace(/<img\b[^>]*\bsrc\s*=\s*["'][^"']*avbeat\.com\/wp-content\/uploads\/[^"']*["'][^>]*\/?>/gi, "");
|
||||
|
||||
// Drop empty <figure></figure> left over after image removal.
|
||||
out = out.replace(/<figure\b[^>]*>\s*(?:<figcaption\b[^>]*>\s*<\/figcaption>\s*)?<\/figure>/gi, "");
|
||||
|
||||
Reference in New Issue
Block a user