This commit is contained in:
parent
b5ce798a06
commit
46f966a860
3 changed files with 7 additions and 6 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 171 KiB After Width: | Height: | Size: 91 KiB |
|
|
@ -7,10 +7,11 @@ import { SITE_TITLE, SITE_METADATA } from '../consts';
|
||||||
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
|
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
|
||||||
|
|
||||||
const { title, description, image, imageAlt } = Astro.props;
|
const { title, description, image, imageAlt } = Astro.props;
|
||||||
|
const defaultOpenGraphImage = SITE_METADATA.openGraph.images[0];
|
||||||
const finalTitle = title || SITE_METADATA.title.default;
|
const finalTitle = title || SITE_METADATA.title.default;
|
||||||
const finalDescription = description || SITE_METADATA.description;
|
const finalDescription = description || SITE_METADATA.description;
|
||||||
const finalImage = image || SITE_METADATA.openGraph.images[0].url;
|
const finalImage = image || defaultOpenGraphImage.url;
|
||||||
const finalImageAlt = imageAlt || finalTitle;
|
const finalImageAlt = imageAlt || (image ? finalTitle : defaultOpenGraphImage.alt);
|
||||||
const imageURL = new URL(finalImage, Astro.url);
|
const imageURL = new URL(finalImage, Astro.url);
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
@ -78,11 +79,11 @@ const imageURL = new URL(finalImage, Astro.url);
|
||||||
<meta property="og:image" content={imageURL} />
|
<meta property="og:image" content={imageURL} />
|
||||||
<meta
|
<meta
|
||||||
property="og:image:width"
|
property="og:image:width"
|
||||||
content={SITE_METADATA.openGraph.images[0].width.toString()}
|
content={defaultOpenGraphImage.width.toString()}
|
||||||
/>
|
/>
|
||||||
<meta
|
<meta
|
||||||
property="og:image:height"
|
property="og:image:height"
|
||||||
content={SITE_METADATA.openGraph.images[0].height.toString()}
|
content={defaultOpenGraphImage.height.toString()}
|
||||||
/>
|
/>
|
||||||
<meta property="og:image:alt" content={finalImageAlt} />
|
<meta property="og:image:alt" content={finalImageAlt} />
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ export const SITE_METADATA = {
|
||||||
url: '/images/og-image.jpg',
|
url: '/images/og-image.jpg',
|
||||||
width: 1200,
|
width: 1200,
|
||||||
height: 630,
|
height: 630,
|
||||||
alt: 'CSE @ IIT Gandhinagar',
|
alt: 'Computer Science and Engineering, IIT Gandhinagar',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
@ -51,6 +51,6 @@ export const SITE_METADATA = {
|
||||||
title: SITE_TITLE,
|
title: SITE_TITLE,
|
||||||
description: SITE_DESCRIPTION,
|
description: SITE_DESCRIPTION,
|
||||||
images: ['/images/og-image.jpg'],
|
images: ['/images/og-image.jpg'],
|
||||||
creator: '@iaboratories',
|
creator: '@cse_iitgn',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue