Improving SEO
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
import { useEffect } from "react";
|
||||
|
||||
interface SEOProps {
|
||||
title: string;
|
||||
description: string;
|
||||
type?: string;
|
||||
image?: string;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
export default function SEO({
|
||||
title,
|
||||
description,
|
||||
type = "website",
|
||||
image = "/logo.png",
|
||||
url,
|
||||
}: SEOProps) {
|
||||
useEffect(() => {
|
||||
const siteName = "Cœur UA PAM";
|
||||
const fullTitle = `${title} | ${siteName}`;
|
||||
|
||||
// Mise à jour du titre de l'onglet
|
||||
document.title = fullTitle;
|
||||
|
||||
// Utilitaire pour mettre à jour ou créer des balises meta
|
||||
const setMeta = (name: string, content: string, isProperty = false) => {
|
||||
const selector = isProperty
|
||||
? `meta[property="${name}"]`
|
||||
: `meta[name="${name}"]`;
|
||||
let element = document.querySelector(selector);
|
||||
if (!element) {
|
||||
element = document.createElement("meta");
|
||||
if (isProperty) element.setAttribute("property", name);
|
||||
else element.setAttribute("name", name);
|
||||
document.head.appendChild(element);
|
||||
}
|
||||
element.setAttribute("content", content);
|
||||
};
|
||||
|
||||
const origin = window.location.origin;
|
||||
const absoluteImage = image.startsWith("http")
|
||||
? image
|
||||
: `${origin}${image}`;
|
||||
const absoluteUrl = url ? `${origin}${url}` : window.location.href;
|
||||
|
||||
// Balises standards
|
||||
setMeta("description", description);
|
||||
|
||||
// Open Graph (Facebook, LinkedIn, etc.)
|
||||
setMeta("og:title", fullTitle, true);
|
||||
setMeta("og:description", description, true);
|
||||
setMeta("og:type", type, true);
|
||||
setMeta("og:url", absoluteUrl, true);
|
||||
setMeta("og:image", absoluteImage, true);
|
||||
setMeta("og:site_name", siteName, true);
|
||||
|
||||
// Twitter
|
||||
setMeta("twitter:card", "summary_large_image");
|
||||
setMeta("twitter:title", fullTitle);
|
||||
setMeta("twitter:description", description);
|
||||
setMeta("twitter:image", absoluteImage);
|
||||
|
||||
// Lien canonique
|
||||
let canonical = document.querySelector('link[rel="canonical"]');
|
||||
if (!canonical) {
|
||||
canonical = document.createElement("link");
|
||||
canonical.setAttribute("rel", "canonical");
|
||||
document.head.appendChild(canonical);
|
||||
}
|
||||
canonical.setAttribute("href", absoluteUrl);
|
||||
}, [title, description, type, image, url]);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -1,8 +1,14 @@
|
||||
import AnimatedContent from "../components/AnimatedContent";
|
||||
import SEO from "../components/SEO";
|
||||
|
||||
const About = () => {
|
||||
return (
|
||||
<div className="w-full pb-20 flex flex-col gap-16 md:gap-24">
|
||||
<SEO
|
||||
title="L'Association"
|
||||
description="Découvrez les missions de Cœur UA PAM : Solidarité, Culture et Entraide. Nos actions pour l'intégration et le soutien logistique en Ukraine."
|
||||
url="/a-propos"
|
||||
/>
|
||||
<AnimatedContent distance={60} direction="vertical" duration={1}>
|
||||
<div className="relative w-full h-[80vh] min-h-125 overflow-hidden shadow-2xl group">
|
||||
<img
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useLayoutEffect, useRef, useState, useCallback } from "react";
|
||||
import AnimatedContent from "../components/AnimatedContent";
|
||||
import SEO from "../components/SEO";
|
||||
|
||||
// --- INTERFACES TYPESCRIPT ---
|
||||
interface EventIntro {
|
||||
@@ -693,6 +694,11 @@ export default function Events() {
|
||||
|
||||
return (
|
||||
<div className="w-full max-w-[100vw] overflow-x-clip pb-20 flex flex-col gap-16 md:gap-24 bg-bg-1">
|
||||
<SEO
|
||||
title="Nos Événements"
|
||||
description="Retrouvez l'historique de nos mobilisations : Octobre Rose, Marchés de Noël, repas solidaires et commémorations."
|
||||
url="/evenements"
|
||||
/>
|
||||
<AnimatedContent distance={60} direction="vertical" duration={1}>
|
||||
<div className="relative w-full h-[80vh] min-h-125 overflow-hidden shadow-2xl group">
|
||||
<img
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useState } from "react";
|
||||
import AnimatedContent from "../components/AnimatedContent";
|
||||
import Stepper, { Step } from "../components/Stepper";
|
||||
import FacebookCarousel from "../components/FacebookCarousel";
|
||||
import SEO from "../components/SEO";
|
||||
|
||||
const StepWithBackground = ({
|
||||
date,
|
||||
@@ -42,6 +43,11 @@ const Historic = () => {
|
||||
|
||||
return (
|
||||
<div className="w-full pb-20 flex flex-col gap-16 md:gap-24">
|
||||
<SEO
|
||||
title="Notre Histoire"
|
||||
description="De l'urgence de mars 2022 à la création officielle de l'association. Découvrez le parcours de solidarité de Cœur UA PAM."
|
||||
url="/notre-histoire"
|
||||
/>
|
||||
<AnimatedContent distance={60} direction="vertical" duration={1}>
|
||||
<div className="relative w-full h-[80vh] min-h-125 overflow-hidden shadow-2xl group">
|
||||
<img
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
import { Link } from "react-router-dom";
|
||||
import AnimatedContent from "../components/AnimatedContent";
|
||||
import CountUp from "../components/ContUp";
|
||||
import SEO from "../components/SEO";
|
||||
|
||||
const Home = () => {
|
||||
return (
|
||||
<div className="w-full pb-20">
|
||||
<SEO
|
||||
title="Accueil"
|
||||
description="Association franco-ukrainienne Cœur UA PAM à Pont-à-Mousson. Soutien humanitaire, aide aux réfugiés et promotion de la culture ukrainienne."
|
||||
url="/"
|
||||
/>
|
||||
<AnimatedContent distance={60} direction="vertical" duration={1}>
|
||||
<div className="relative w-full h-[80vh] min-h-150 overflow-hidden mb-12 shadow-2xl group">
|
||||
<img
|
||||
|
||||
Reference in New Issue
Block a user