Extract contants from Meta component

This commit is contained in:
Ricardo Tribaldos 2024-03-27 16:57:42 -05:00
parent 9caf68d975
commit 827086c49d
2 changed files with 46 additions and 24 deletions

View file

@ -1,25 +1,13 @@
--- ---
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. // Default properties for the Meta component. These values are used if props are not provided.
// 'title' sets the default page title for the website.
// 'meta' sets a default description meta tag to describe the page content. // '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). // 'structuredData' defines default structured data in JSON-LD format to enhance search engine understanding of the page (for SEO purposes).
const defaultProps = { const defaultProps = {
meta: "ScrewFast offers top-tier hardware tools and expert construction services to meet all your project needs. Start exploring and contact our sales team for superior quality and reliability.", meta: SITE.description,
structuredData: { structuredData: SEO.structuredData,
"@context": "https://schema.org",
"@type": "WebPage",
"@id": "https://screwfast.uk",
"url": "https://screwfast.uk",
"name": "ScrewFast | Top-quality Hardware Tools",
"description": "ScrewFast offers top-tier hardware tools and expert construction services to meet all your project needs.",
"isPartOf": {
"@type": "WebSite",
"url": "https://screwfast.uk",
"name": "ScrewFast",
"description": "ScrewFast offers top-tier hardware tools and expert construction services to meet all your project needs."
},
"inLanguage": "en-US"
},
}; };
// 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.
@ -28,12 +16,10 @@ const defaultProps = {
const { meta = defaultProps.meta, structuredData = defaultProps.structuredData } = Astro.props; const { meta = defaultProps.meta, structuredData = defaultProps.structuredData } = Astro.props;
// Define the metadata for your website and individual pages // Define the metadata for your website and individual pages
const title: string = "ScrewFast"; // Set default title const URL = `${Astro.site}`; // Set the website URL in astro.config.mjs
const ogTitle: string = "ScrewFast: Hardware Tools & Construction Services"; // Set the Open Graph title const author = SITE.author;
const author: string = "Emil Gulamov"; // Set the author's name const ogTitle = OG.title;
const ogDescription: string = const ogDescription = OG.description;
"Equip your projects with ScrewFast's top-quality hardware tools and expert construction services. Trusted by industry leaders, ScrewFast offers simplicity, affordability, and reliability. Experience the difference with user-centric design and cutting-edge tools. Start exploring now!"; // Set the Open Graph description
const URL: string = `${Astro.site}`; // Set the website URL in astro.config.mjs
const socialImage: string = `${Astro.site}/social.png`; // Set the path for the social media image const socialImage: string = `${Astro.site}/social.png`; // Set the path for the social media image
--- ---
@ -57,7 +43,7 @@ const socialImage: string = `${Astro.site}/social.png`; // Set the path for the
<meta property="og:url" content={URL} /> <meta property="og:url" content={URL} />
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<meta property="og:title" content={ogTitle} /> <meta property="og:title" content={ogTitle} />
<meta property="og:site_name" content={title} /> <meta property="og:site_name" content={SITE.title} />
<meta property="og:description" content={ogDescription} /> <meta property="og:description" content={ogDescription} />
<meta property="og:image" content={socialImage} /> <meta property="og:image" content={socialImage} />
<meta content="1200" property="og:image:width" /> <meta content="1200" property="og:image:width" />

View file

@ -0,0 +1,36 @@
export const SITE = {
title: "ScrewFast",
tagline: "Top-quality Hardware Tools",
description: "ScrewFast offers top-tier hardware tools and expert construction services to meet all your project needs. Start exploring and contact our sales team for superior quality and reliability.",
description_short: "ScrewFast offers top-tier hardware tools and expert construction services to meet all your project needs.",
url: "https://screwfast.uk",
author: "Emil Gulamov",
};
export const SEO = {
title: SITE.title,
description: SITE.description,
structuredData: {
"@context": "https://schema.org",
"@type": "WebPage",
inLanguage: "en-US",
"@id": SITE.url,
url: SITE.url,
name: SITE.title,
description: SITE.description,
isPartOf: {
"@type": "WebSite",
url: SITE.url,
name: SITE.title,
description: SITE.description,
},
},
};
export const OG = {
locale: "en_US",
type: "website",
url: SITE.url,
title: `${SITE.title}: : Hardware Tools & Construction Services`,
description: "Equip your projects with ScrewFast's top-quality hardware tools and expert construction services. Trusted by industry leaders, ScrewFast offers simplicity, affordability, and reliability. Experience the difference with user-centric design and cutting-edge tools. Start exploring now!",
};