Trim description clutter: strip URLs in cards, tighter preview in Watch

- VideoCard list variant: strip URLs/affiliate links before rendering,
  collapse to 1 line (was 2 lines of raw text including https:// spam)
- DescriptionBox collapsed preview: 2 lines / 200 chars before "Show more"
  (was 4 lines — too much affiliate crap before you can dismiss it)
- Full description still shown when expanded in Watch view

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mattias Tall
2026-05-26 16:53:01 +02:00
parent 3e3d2c7464
commit d6035e6f1f
2 changed files with 15 additions and 6 deletions

View File

@@ -4,6 +4,15 @@ import { useNavigate } from "react-router-dom";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { createDownload, toggleQueue, toggleLike, dismissDiscovery, getSettings } from "../api";
function snippetText(desc) {
if (!desc) return "";
return desc
.replace(/https?:\/\/\S+/g, "") // strip URLs
.replace(/\n+/g, " ") // flatten newlines
.replace(/\s{2,}/g, " ") // collapse whitespace
.trim();
}
function formatDuration(secs) {
if (!secs) return null;
const h = Math.floor(secs / 3600);
@@ -302,10 +311,10 @@ export default function VideoCard({ video, size = "md", onDismiss, variant = "gr
)}
</div>
{/* Description — desktop only, 2 lines max */}
{video.description && (
<p className="hidden sm:block text-[11px] leading-relaxed text-zinc-500 line-clamp-2">
{video.description.replace(/\n+/g, " ")}
{/* Description snippet — desktop only, URLs stripped */}
{video.description && snippetText(video.description) && (
<p className="hidden sm:block text-[11px] leading-relaxed text-zinc-500 line-clamp-1">
{snippetText(video.description)}
</p>
)}