SEO оптимизация

This commit is contained in:
RoyceDa
2026-02-16 17:27:28 +02:00
parent 20fc9eed8a
commit 01a1856ba1
5 changed files with 123 additions and 3 deletions

View File

@@ -0,0 +1,44 @@
import { useEffect } from 'react';
interface SEOProps {
title?: string;
description?: string;
ogImage?: string;
keywords?: string;
}
export function SEO({
title = 'Rosetta - Secure Messaging for Everyone',
description = 'End-to-end encrypted messaging app with military-grade security. Download for macOS, Windows, Linux.',
ogImage = '/og-image.png',
keywords = 'secure messaging, encrypted chat, private messenger'
}: SEOProps) {
useEffect(() => {
// Update title
document.title = title;
// Update meta tags
updateMetaTag('name', 'description', description);
updateMetaTag('name', 'keywords', keywords);
updateMetaTag('property', 'og:title', title);
updateMetaTag('property', 'og:description', description);
updateMetaTag('property', 'og:image', ogImage);
updateMetaTag('name', 'twitter:title', title);
updateMetaTag('name', 'twitter:description', description);
updateMetaTag('name', 'twitter:image', ogImage);
}, [title, description, ogImage, keywords]);
return null;
}
function updateMetaTag(attr: string, name: string, content: string) {
let element = document.querySelector(`meta[${attr}="${name}"]`);
if (!element) {
element = document.createElement('meta');
element.setAttribute(attr, name);
document.head.appendChild(element);
}
element.setAttribute('content', content);
}