Move support into React Router

This commit is contained in:
rosetta
2026-07-30 16:47:54 -07:00
parent c81c3a1189
commit 650d73830f
11 changed files with 378 additions and 838 deletions

View File

@@ -3,7 +3,6 @@ import { useEffect } from 'react';
interface SEOProps {
title?: string;
description?: string;
ogImage?: string;
keywords?: string;
canonical?: string;
}
@@ -11,7 +10,6 @@ interface SEOProps {
export function SEO({
title = 'Rosetta - Secure Messaging for Everyone',
description = 'End-to-end encrypted messaging app with military-grade security. Download for Windows, Linux, and Android.',
ogImage = '/og.png',
keywords = 'secure messaging, encrypted chat, private messenger',
canonical = 'https://rosetta.im/'
}: SEOProps) {
@@ -22,14 +20,14 @@ export function SEO({
updateMetaTag('name', 'keywords', keywords);
updateMetaTag('property', 'og:title', title);
updateMetaTag('property', 'og:description', description);
updateMetaTag('property', 'og:image', ogImage);
updateMetaTag('property', 'og:url', canonical);
updateMetaTag('name', 'twitter:title', title);
updateMetaTag('name', 'twitter:description', description);
updateMetaTag('name', 'twitter:image', ogImage);
updateMetaTag('name', 'twitter:url', canonical);
removeMetaTag('property', 'og:image');
removeMetaTag('name', 'twitter:image');
updateCanonical(canonical);
}, [title, description, ogImage, keywords, canonical]);
}, [title, description, keywords, canonical]);
return null;
}
@@ -46,6 +44,10 @@ function updateMetaTag(attr: string, name: string, content: string) {
element.setAttribute('content', content);
}
function removeMetaTag(attr: string, name: string) {
document.querySelector(`meta[${attr}="${name}"]`)?.remove();
}
function updateCanonical(href: string) {
let element = document.querySelector<HTMLLinkElement>('link[rel="canonical"]');