A Astro blog hosted on Vercel

update head meta elements

Changed files
+25 -14
src
components
organisms
layouts
pages
+23 -4
src/components/organisms/Head.astro
··· 2 2 // Import the global.css file here so that it is included on 3 3 // all pages through the use of the <BaseHead /> component. 4 4 import "@/styles/global.css"; 5 + import type { CollectionEntry } from "astro:content"; 5 6 6 7 interface Props { 7 8 title: string; 8 9 description: string; 9 - image?: string; 10 + image?: CollectionEntry<"gallery">["data"]["image"]; 10 11 } 11 12 12 13 const canonicalURL = new URL(Astro.url.pathname, Astro.site); 13 14 14 - const { title, description, image = "/blog-placeholder-1.jpg" } = Astro.props; 15 + const { 16 + title, 17 + description, 18 + image 19 + } = Astro.props; 15 20 --- 16 21 17 22 <!-- Global Metadata --> ··· 52 57 <meta property="og:url" content={Astro.url} /> 53 58 <meta property="og:title" content={title} /> 54 59 <meta property="og:description" content={description} /> 55 - <meta property="og:image" content={new URL(image, Astro.url)} /> 60 + <meta property="og:site_name" content="claycow" /> 61 + { 62 + image && ( 63 + <meta property="og:image" content={new URL(image.src, Astro.url)} /> 64 + <meta property="og:image:type" content="image/webp" /> 65 + <meta property="og:image:alt" content={description} /> 66 + ) 67 + } 56 68 57 69 <!-- Twitter --> 58 70 <meta property="twitter:card" content="summary_large_image" /> 59 71 <meta property="twitter:url" content={Astro.url} /> 60 72 <meta property="twitter:title" content={title} /> 61 73 <meta property="twitter:description" content={description} /> 62 - <meta property="twitter:image" content={new URL(image, Astro.url)} /> 74 + { 75 + image && ( 76 + <meta 77 + property="twitter:image" 78 + content={new URL(image.src, Astro.url)} 79 + /> 80 + ) 81 + }
+1 -1
src/layouts/GalleryPost.astro
··· 12 12 13 13 <html lang="en"> 14 14 <head> 15 - <Head title={title} description={alt} /> 15 + <Head title={title} description={alt} image={image} /> 16 16 <style> 17 17 article { 18 18 display: flex;
-3
src/pages/gallery/[...slug].astro
··· 1 1 --- 2 2 import { type CollectionEntry, getCollection } from "astro:content"; 3 - import BlogPost from "@/layouts/BlogPost.astro"; 4 - import { render } from "astro:content"; 5 3 import GalleryPost from "@/layouts/GalleryPost.astro"; 6 4 7 5 export async function getStaticPaths() { ··· 16 14 type Props = CollectionEntry<"gallery">; 17 15 18 16 const post = Astro.props; 19 - const { Content } = await render(post); 20 17 --- 21 18 22 19 <GalleryPost {...post.data} />
+1 -6
src/pages/gallery/index.astro
··· 1 1 --- 2 - import { 3 - Head, 4 - Footer, 5 - Navigation, 6 - BlogPreviewCard, 7 - } from "@/components/organisms"; 2 + import { Head, Footer, Navigation } from "@/components/organisms"; 8 3 import { SITE_TITLE, SITE_DESCRIPTION } from "@/consts"; 9 4 import { getCollection } from "astro:content"; 10 5 import SpeedInsights from "@vercel/speed-insights/astro";