Ensure social sharing links use the correct domain
Update share buttons and copy link functionality to consistently use the canonical domain (https://www.folx.tv) for all generated URLs, resolving issues with social media scraping and display. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 1f7e7e89-a520-4970-9645-37daadc466dc Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 0050f02e-3b94-4ac8-92d6-d75766bae769 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/1f7e7e89-a520-4970-9645-37daadc466dc/ZApZ5Qi Replit-Helium-Checkpoint-Created: true
This commit is contained in:
parent
0e8bcc9d41
commit
7544820153
@ -8,6 +8,17 @@ interface ShareButtonsProps {
|
|||||||
image?: string;
|
image?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CANONICAL_DOMAIN = "https://www.folx.tv";
|
||||||
|
|
||||||
|
function canonicalUrl(url: string): string {
|
||||||
|
try {
|
||||||
|
const parsed = new URL(url);
|
||||||
|
return `${CANONICAL_DOMAIN}${parsed.pathname}${parsed.search}${parsed.hash}`;
|
||||||
|
} catch {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const SHARE_TARGETS = [
|
const SHARE_TARGETS = [
|
||||||
{
|
{
|
||||||
name: "Facebook",
|
name: "Facebook",
|
||||||
@ -58,12 +69,12 @@ export default function ShareButtons({ url, title, image }: ShareButtonsProps) {
|
|||||||
|
|
||||||
const handleCopy = async () => {
|
const handleCopy = async () => {
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(url);
|
await navigator.clipboard.writeText(canonicalUrl(url));
|
||||||
setCopied(true);
|
setCopied(true);
|
||||||
setTimeout(() => setCopied(false), 2000);
|
setTimeout(() => setCopied(false), 2000);
|
||||||
} catch {
|
} catch {
|
||||||
const input = document.createElement("input");
|
const input = document.createElement("input");
|
||||||
input.value = url;
|
input.value = canonicalUrl(url);
|
||||||
document.body.appendChild(input);
|
document.body.appendChild(input);
|
||||||
input.select();
|
input.select();
|
||||||
document.execCommand("copy");
|
document.execCommand("copy");
|
||||||
@ -79,7 +90,7 @@ export default function ShareButtons({ url, title, image }: ShareButtonsProps) {
|
|||||||
{SHARE_TARGETS.map((target) => (
|
{SHARE_TARGETS.map((target) => (
|
||||||
<a
|
<a
|
||||||
key={target.name}
|
key={target.name}
|
||||||
href={target.getUrl(url, title, image)}
|
href={target.getUrl(canonicalUrl(url), title, image ? canonicalUrl(image) : undefined)}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className={`inline-flex items-center justify-center w-9 h-9 rounded-full border border-border text-muted-foreground transition-all duration-200 ${target.color}`}
|
className={`inline-flex items-center justify-center w-9 h-9 rounded-full border border-border text-muted-foreground transition-all duration-200 ${target.color}`}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user