Refactor components to 'sections' directory and improve SEO

All component files have been moved to a newly created 'sections' directory for better organization. Changes in import paths are reflected in all dependent files. Also, implemented SEO enhancements by adding structured data and default meta descriptions to the Meta component, and adjusted it to accept these values as props from parent components.
This commit is contained in:
Emil Gulamov 2024-02-19 17:41:42 +04:00
parent 5b8218c5e5
commit 7a609e4a5c
21 changed files with 41 additions and 37 deletions

View file

@ -1,15 +1,26 @@
--- ---
// Assign a description using the `meta` prop passed from the parent component, // Default properties for the Meta component. These values are used if props are not provided.
// `meta` is used as a variable on each individual page by passing it as a prop to this component. // 'title' sets the default page title for the website.
// For example, you can pass a meta description to the MainLayout component like this: <MainLayout meta="Page description"/> // 'meta' sets a default description meta tag to describe the page content.
const { meta: description } = Astro.props; // 'structuredData' defines default structured data in JSON-LD format to enhance search engine understanding of the page (for SEO purposes).
const defaultProps = {
title: "ScrewFast", // Default title
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.",
structuredData: {
"@context": "https://schema.org",
"@type": "WebSite",
"name": "ScrewFast",
"url": "https://screwfast.uk",
"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.",
},
};
interface Props { // Extract props with default values assigned from defaultProps. Values can be overridden when the component is used.
meta?: string; // For example:
} // <MainLayout title="Custom Title" meta="Custom description." />
const { title = defaultProps.title, 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 the website title
const ogTitle: string = "ScrewFast: Hardware Tools & Construction Services"; // Set the Open Graph title const ogTitle: string = "ScrewFast: Hardware Tools & Construction Services"; // Set the Open Graph title
const author: string = "Emil Gulamov"; // Set the author's name const author: string = "Emil Gulamov"; // Set the author's name
const ogDescription: string = const ogDescription: string =
@ -18,19 +29,14 @@ const URL: string = "https://screwfast.uk"; // Set the website URL
const socialImage: string = "https://screwfast.uk/social.png"; // Set the URL for the social media image const socialImage: string = "https://screwfast.uk/social.png"; // Set the URL for the social media image
--- ---
<!-- JSON-LD structured data script for the website --> <!-- Inject structured data into the page if provided. This data is formatted as JSON-LD, a method recommended by Google for structured data pass:
<script type="application/ld+json"> https://developers.google.com/search/docs/advanced/structured-data/intro-structured-data -->
{ {structuredData && (
"@context": "https://schema.org", <script type="application/ld+json" set:html={JSON.stringify(structuredData)}></script>
"@type": "WebSite", )}
"name": "ScrewFast",
"url": "https://screwfast.uk",
"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."
}
</script>
<!-- Define the character set, description, author, and viewport settings --> <!-- Define the character set, description, author, and viewport settings -->
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta content={description} name="description" /> <meta content={meta} name="description" />
<meta name="web_author" content={author} /> <meta name="web_author" content={author} />
<meta <meta
name="viewport" name="viewport"

View file

@ -5,12 +5,13 @@ import Navbar from "../components/Navbar.astro";
import FooterSection from "../components/FooterSection.astro"; import FooterSection from "../components/FooterSection.astro";
// Setting expected props - expecting 'title' and 'meta' as options with a default value for title // Setting expected props - expecting 'title' and 'meta' as options with a default value for title
const { title = "ScrewFast", meta } = Astro.props; const { title = "ScrewFast", meta, structuredData } = Astro.props;
// Interface to type-check the properties // Interface to type-check the properties
interface Props { interface Props {
title?: string; title?: string;
meta?: string; meta?: string;
structuredData?: object;
} }
--- ---
@ -21,7 +22,7 @@ We set the language of the page to English and add classes for scrollbar and scr
<html lang="en" class="scrollbar-hide scroll-pt-16"> <html lang="en" class="scrollbar-hide scroll-pt-16">
<head> <head>
<!-- Adding metadata to the HTML document --> <!-- Adding metadata to the HTML document -->
<Meta meta={meta} /> <Meta meta={meta} structuredData={structuredData} />
<!-- Define the title of the page --> <!-- Define the title of the page -->
<title>{title}</title> <title>{title}</title>
<script is:inline> <script is:inline>

View file

@ -1,7 +1,7 @@
--- ---
// Import the necessary components // Import the necessary components
import MainLayout from "../layouts/MainLayout.astro"; import MainLayout from "../layouts/MainLayout.astro";
import ContactSection from "../components/ContactSection.astro"; import ContactSection from "../components/sections/ContactSection.astro";
--- ---
<!--Utilizing MainLayout for the outer layout of the page, and defining meta for SEO purposes--> <!--Utilizing MainLayout for the outer layout of the page, and defining meta for SEO purposes-->

View file

@ -1,14 +1,14 @@
--- ---
// Import the necessary components // Import the necessary components
import MainLayout from "../layouts/MainLayout.astro"; import MainLayout from "../layouts/MainLayout.astro";
import HeroSection from "../components/HeroSection.astro"; import HeroSection from "../components/sections/HeroSection.astro";
import HeroSectionAlt from "../components/HeroSectionAlt.astro"; import HeroSectionAlt from "../components/sections/HeroSectionAlt.astro";
import ClientsSection from "../components/ClientsSection.astro"; import ClientsSection from "../components/sections/ClientsSection.astro";
import FeaturesGeneral from "../components/FeaturesGeneral.astro"; import FeaturesGeneral from "../components/sections/FeaturesGeneral.astro";
import FeaturesNavs from "../components/FeaturesNavs.astro"; import FeaturesNavs from "../components/sections/FeaturesNavs.astro";
import TestimonialsSection from "../components/TestimonialsSection.astro"; import TestimonialsSection from "../components/sections/TestimonialsSection.astro";
import PricingSection from "../components/PricingSection.astro"; import PricingSection from "../components/sections/PricingSection.astro";
import FAQ from "../components/FAQ.astro"; import FAQ from "../components/sections/FAQ.astro";
--- ---
<!--Utilizing MainLayout for the outer layout of the page, and defining meta for SEO purposes--> <!--Utilizing MainLayout for the outer layout of the page, and defining meta for SEO purposes-->

View file

@ -4,8 +4,8 @@ import MainLayout from "../../layouts/MainLayout.astro";
import PrimaryCTA from "../../components/ui/buttons/PrimaryCTA.astro"; import PrimaryCTA from "../../components/ui/buttons/PrimaryCTA.astro";
import CardSmall from "../../components/ui/cards/CardSmall.astro"; import CardSmall from "../../components/ui/cards/CardSmall.astro";
import CardWide from "../../components/ui/cards/CardWide.astro"; import CardWide from "../../components/ui/cards/CardWide.astro";
import FeaturesStatsAlt from "../../components/FeaturesStatsAlt.astro"; import FeaturesStatsAlt from "../../components/sections/FeaturesStatsAlt.astro";
import TestimonialsSectionAlt from "../../components/TestimonialsSectionAlt.astro"; import TestimonialsSectionAlt from "../../components/sections/TestimonialsSectionAlt.astro";
// Importing necessary functions from Astro // Importing necessary functions from Astro
import { getCollection } from "astro:content"; import { getCollection } from "astro:content";
@ -26,10 +26,7 @@ const subTitle: string =
--- ---
<!--Utilizing MainLayout for the outer layout of the page, and defining meta for SEO purposes--> <!--Utilizing MainLayout for the outer layout of the page, and defining meta for SEO purposes-->
<MainLayout <MainLayout title="Products | ScrewFast">
title="Products | ScrewFast"
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."
>
<div <div
class="mx-auto max-w-[85rem] px-4 py-10 sm:px-6 lg:px-8 lg:py-14 2xl:max-w-full" class="mx-auto max-w-[85rem] px-4 py-10 sm:px-6 lg:px-8 lg:py-14 2xl:max-w-full"
> >

View file

@ -4,7 +4,7 @@ import MainLayout from "../layouts/MainLayout.astro";
import MainSection from "../components/ui/blocks/MainSection.astro"; import MainSection from "../components/ui/blocks/MainSection.astro";
import LeftSection from "../components/ui/blocks/LeftSection.astro"; import LeftSection from "../components/ui/blocks/LeftSection.astro";
import RightSection from "../components/ui/blocks/RightSection.astro"; import RightSection from "../components/ui/blocks/RightSection.astro";
import FeaturesStats from "../components/FeaturesStats.astro"; import FeaturesStats from "../components/sections/FeaturesStats.astro";
// Import necessary images // Import necessary images
import blueprints from "../images/blueprints-image.avif"; import blueprints from "../images/blueprints-image.avif";