achat-maison-albi-fr/src/components/Meta.astro

74 lines
3.3 KiB
Text
Raw Normal View History

---
2024-03-27 16:57:42 -05:00
import { getImage } from "astro:assets";
import { OG, SEO, SITE } from "@/data_files/constants";
// Default properties for the Meta component. These values are used if props are not provided.
// 'meta' sets a default description meta tag to describe the page content.
// 'structuredData' defines default structured data in JSON-LD format to enhance search engine understanding of the page (for SEO purposes).
const defaultProps = {
2024-03-27 16:57:42 -05:00
meta: SITE.description,
structuredData: SEO.structuredData,
};
// Extract props with default values assigned from defaultProps. Values can be overridden when the component is used.
// For example:
// <MainLayout title="Custom Title" meta="Custom description." />
const { meta = defaultProps.meta, structuredData = defaultProps.structuredData } = Astro.props;
// Define the metadata for your website and individual pages
2024-03-27 16:57:42 -05:00
const URL = `${Astro.site}`; // Set the website URL in astro.config.mjs
const author = SITE.author;
const ogTitle = OG.title;
const ogDescription = OG.description;
const socialImage: string = `${Astro.site}/social.png`; // Set the path for the social media image
---
<!-- Inject structured data into the page if provided. This data is formatted as JSON-LD, a method recommended by Google for structured data pass:
https://developers.google.com/search/docs/advanced/structured-data/intro-structured-data -->
{structuredData && (
<script type="application/ld+json" set:html={JSON.stringify(structuredData)}></script>
)}
<!-- Define the character set, description, author, and viewport settings -->
<meta charset="utf-8" />
<meta content={meta} name="description" />
<meta name="web_author" content={author} />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=5.0, minimum-scale=1.0"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<!-- Facebook Meta Tags -->
<meta property="og:locale" content="en_US" />
<meta property="og:url" content={URL} />
<meta property="og:type" content="website" />
<meta property="og:title" content={ogTitle} />
2024-03-27 16:57:42 -05:00
<meta property="og:site_name" content={SITE.title} />
<meta property="og:description" content={ogDescription} />
<meta property="og:image" content={socialImage} />
<meta content="1200" property="og:image:width" />
<meta content="600" property="og:image:height" />
<meta content="image/png" property="og:image:type" />
<!-- Twitter Meta Tags -->
<meta name="twitter:card" content="summary_large_image" />
<meta property="twitter:domain" content={URL} />
<meta property="twitter:url" content={URL} />
<meta name="twitter:title" content={ogTitle} />
<meta name="twitter:description" content={ogDescription} />
<meta name="twitter:image" content={socialImage} />
<!-- Links to the webmanifest and sitemap -->
<link rel="manifest" href="/manifest.webmanifest" />
<!-- https://docs.astro.build/en/guides/integrations-guide/sitemap/ -->
<link rel="sitemap" href="/sitemap-index.xml" />
<!-- Links for favicons -->
<link href="/favicon.ico" rel="icon" sizes="any" type="image/x-icon" />
<link href="/icon.svg" rel="icon" type="image/svg+xml" sizes="any" />
<meta name="mobile-web-app-capable" content="yes" />
<link href="/apple-touch-icon.png" rel="apple-touch-icon" />
<link href="/apple-touch-icon.png" rel="shortcut icon" />
<!-- Set theme color -->
<meta name="theme-color" content="#facc15" />