From b85932416df97114556fa3f7660edbb566537f2e Mon Sep 17 00:00:00 2001 From: prototypa Date: Sun, 14 Aug 2022 17:34:54 -0400 Subject: [PATCH] Fix SEO problem with metatags --- src/components/astro/utils/BasicScripts.astro | 25 +++++++ src/components/astro/utils/MetaTags.astro | 53 ++++++++++++++ src/layouts/Default.astro | 70 ++----------------- src/layouts/Empty.astro | 27 ++----- 4 files changed, 89 insertions(+), 86 deletions(-) create mode 100644 src/components/astro/utils/BasicScripts.astro create mode 100644 src/components/astro/utils/MetaTags.astro diff --git a/src/components/astro/utils/BasicScripts.astro b/src/components/astro/utils/BasicScripts.astro new file mode 100644 index 0000000..aa33a9d --- /dev/null +++ b/src/components/astro/utils/BasicScripts.astro @@ -0,0 +1,25 @@ +--- +const {} = Astro.props; +--- + + diff --git a/src/components/astro/utils/MetaTags.astro b/src/components/astro/utils/MetaTags.astro new file mode 100644 index 0000000..385e4b4 --- /dev/null +++ b/src/components/astro/utils/MetaTags.astro @@ -0,0 +1,53 @@ +--- +import { getImage } from "@astrojs/image"; + +const { src: defaultImage } = await getImage({ + src: import("~/assets/images/hero.jpg"), + width: 768, + aspectRatio: "16:9", +}); + +const { + title = "AstroWind", + description = "A template to make your website using Astro + Tailwind CSS.", + image = defaultImage, +} = Astro.props; + +const canonicalURL = new URL(Astro.url.pathname, Astro.site); +const absoluteImageUrl = new URL(image, Astro.site); +--- + + + + + +{title} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/layouts/Default.astro b/src/layouts/Default.astro index b905a74..faf9dc9 100644 --- a/src/layouts/Default.astro +++ b/src/layouts/Default.astro @@ -3,56 +3,16 @@ import "~/assets/styles/base.css"; import Header from "~/components/astro/headers/BasicHeader.astro"; import Footer from "~/components/astro/footers/BasicFooter.astro"; +import MetaTags from "~/components/astro/utils/MetaTags.astro"; +import BasicScripts from "~/components/astro/utils/BasicScripts.astro"; -import { getImage } from "@astrojs/image"; - -const { src: defaultImage } = await getImage({ - src: import("~/assets/images/hero.jpg"), - width: 768, - aspectRatio: "16:9" -}) - -const { - title = "AstroWind", - description = "A template to make your website using Astro + Tailwind CSS.", - image = defaultImage, - withHeader = true, -} = Astro.props; +const { title, description, image } = Astro.props; --- - - - - - {title} - - - - - - - - - - - - - - - - - - - - - - - - +