fix: og image

This commit is contained in:
OLIMINATOR 2023-01-07 13:42:24 +01:00
parent 33b1a84fd9
commit 13ac49f60d
2 changed files with 17 additions and 4 deletions

View file

@ -1,5 +1,17 @@
---
import { getImage } from '@astrojs/image';
import { SITE, OPEN_GRAPH } from '../config';
const defaultImage = OPEN_GRAPH.image.src
? (
await getImage({
src: OPEN_GRAPH.image.src,
alt: OPEN_GRAPH.image.alt,
width: 640,
height: 320,
})
).src
: '';
---
<!-- Primary Meta Tags -->
@ -13,7 +25,7 @@ import { SITE, OPEN_GRAPH } from '../config';
<meta property="og:site_name" content={SITE.title} />
<meta property="og:title" content={SITE.title} />
<meta property="og:description" content={SITE.description} />
<meta property="og:image" content={OPEN_GRAPH.image.src} />
<meta property="og:image" content={defaultImage} />
<meta property="og:image:alt" content={OPEN_GRAPH.image.alt} />
<!-- Twitter -->
@ -22,7 +34,7 @@ import { SITE, OPEN_GRAPH } from '../config';
<meta property="twitter:url" content={SITE.url} />
<meta property="twitter:title" content={SITE.title} />
<meta property="twitter:description" content={SITE.description} />
<meta property="twitter:image" content={OPEN_GRAPH.image.src} />
<meta property="twitter:image" content={defaultImage} />
<meta name="twitter:image:alt" content={OPEN_GRAPH.image.alt} />
<meta name="theme-color" content={SITE.themeColor} />

View file

@ -7,7 +7,7 @@ export const SITE = {
export const OPEN_GRAPH = {
image: {
src: './src/assets/images/og-image.png',
src: '../src/assets/images/og-image.png',
alt: 'Odkazy text s tlačítkami',
},
twitter: 'oliminator34',
@ -19,6 +19,7 @@ export const BUTTONS = [
background: 'bg-youtube hover:bg-youtube/80',
href: '/',
},
/*
{
name: 'Instagram',
background: 'bg-instagram hover:bg-instagram/80',
@ -48,5 +49,5 @@ export const BUTTONS = [
name: 'Twitter',
background: 'bg-twitter hover:bg-twitter/80',
href: '/',
},
},*/
];