articles: strip dead WP image tags from imported post bodies
rewriteLegacyImageUrlsInHtml only swapped URLs that had a mapping in legacy-image-map.json — anything missing the map was left pointing at the dead https://www.broadcastbeat.com/wp-content/uploads/ host (404 in browsers, bad for SEO, broken-image icons everywhere). New stripDeadLegacyImages() pass runs after the rewrite and removes: - <figure> blocks whose only inner image is a dead WP image - <a> wrappers around dead images - Bare <img dead> tags - Empty <figure> leftovers …leaving body copy intact and figcaption-less. cleanLegacyImages() is the one-call helper that pipes both steps. Applied via rowToArticle so every /news/<slug> render gets it.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { createClient } from "@supabase/supabase-js";
|
||||
import type { Article } from "./types";
|
||||
import { rewriteLegacyImageUrl, rewriteLegacyImageUrlsInHtml } from "@/lib/legacy-image";
|
||||
import { rewriteLegacyImageUrl, cleanLegacyImages } from "@/lib/legacy-image";
|
||||
|
||||
const SUPABASE_URL = process.env.NEXT_PUBLIC_SUPABASE_URL!;
|
||||
const SUPABASE_ANON = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!;
|
||||
@@ -128,7 +128,7 @@ function rowToArticle(row: ImportedPostRow, section: Section = "news"): Article
|
||||
const image = row.featured_image
|
||||
? rewriteLegacyImageUrl(row.featured_image)
|
||||
: FALLBACK_IMAGE;
|
||||
const content = rewriteLegacyImageUrlsInHtml(row.content || "");
|
||||
const content = cleanLegacyImages(row.content || "");
|
||||
const author = row.author_name || "Broadcast Beat";
|
||||
return {
|
||||
slug: row.wp_slug,
|
||||
|
||||
Reference in New Issue
Block a user