feat: amélioration des meta og

This commit is contained in:
Jalil Arfaoui 2025-01-09 19:22:45 +01:00
parent 2c3519ca47
commit e940d966e4

View file

@ -11,6 +11,8 @@ const defaultProps = {
structuredData: SEO.structuredData, structuredData: SEO.structuredData,
}; };
const sd = SEO.structuredData;
// Extract props with default values assigned from defaultProps. Values can be overridden when the component is used. // Extract props with default values assigned from defaultProps. Values can be overridden when the component is used.
// For example: // For example:
// <MainLayout title="Custom Title" meta="Custom description." /> // <MainLayout title="Custom Title" meta="Custom description." />
@ -31,7 +33,7 @@ const socialImageRes = await getImage({
width: 1200, width: 1200,
height: 600, height: 600,
}); });
const socialImage = structuredData.image || Astro.url.origin + socialImageRes.src; // Get the full URL of the image (https://stackoverflow.com/a/9858694) const socialImage = (Astro.url.origin + structuredData.image?.src.toString()) || Astro.url.origin + socialImageRes.src; // Get the full URL of the image (https://stackoverflow.com/a/9858694)
const languages: { [key: string]: string } = { const languages: { [key: string]: string } = {
en: "", en: "",
@ -48,17 +50,6 @@ function createHref(lang: string, prefix: string, path: string): string {
const fullPath: string = Astro.url.pathname; const fullPath: string = Astro.url.pathname;
const alternateLanguageLinks: string = Object.entries(languages)
.map(([lang, prefix]: [string, string]) => {
const basePath: string =
lang === "en" ? fullPath.replace(/^\/fr\//, "/") : fullPath;
const href: string = createHref(lang, prefix, basePath);
return `<link rel="alternate" hreflang="${lang}" href="${href}" />`;
})
.join("\n");
const appleTouchIcon = await getImage({ const appleTouchIcon = await getImage({
src: faviconSrc, src: faviconSrc,
@ -87,7 +78,6 @@ const appleTouchIcon = await getImage({
/> />
<meta http-equiv="X-UA-Compatible" content="ie=edge" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="canonical" href={canonical} /> <link rel="canonical" href={canonical} />
<Fragment set:html={alternateLanguageLinks} />
<!-- Facebook Meta Tags --> <!-- Facebook Meta Tags -->
<meta property="og:locale" content="fr_FR" /> <meta property="og:locale" content="fr_FR" />