Fixed opengraph again
All checks were successful
Docker Deploy / build-and-push (push) Successful in 4m4s
All checks were successful
Docker Deploy / build-and-push (push) Successful in 4m4s
This commit is contained in:
@@ -143,7 +143,13 @@ export const config: Config = {
|
|||||||
author: "Atridad Lahiji",
|
author: "Atridad Lahiji",
|
||||||
},
|
},
|
||||||
openGraph: {
|
openGraph: {
|
||||||
image: "/logo.png",
|
image: {
|
||||||
|
url: "/logo.webp",
|
||||||
|
width: 1024,
|
||||||
|
height: 1024,
|
||||||
|
type: "image/webp",
|
||||||
|
alt: "Atridad Lahiji",
|
||||||
|
},
|
||||||
type: "website",
|
type: "website",
|
||||||
locale: "en_US",
|
locale: "en_US",
|
||||||
siteName: "Atridad Lahiji",
|
siteName: "Atridad Lahiji",
|
||||||
|
|||||||
@@ -3,13 +3,14 @@ import { ClientRouter } from "astro:transitions";
|
|||||||
import NavigationBar from "../components/NavigationBar.vue";
|
import NavigationBar from "../components/NavigationBar.vue";
|
||||||
import ScrollUpButton from "../components/ScrollUpButton.vue";
|
import ScrollUpButton from "../components/ScrollUpButton.vue";
|
||||||
import { config } from "../config";
|
import { config } from "../config";
|
||||||
|
import type { OpenGraphImage } from "../types";
|
||||||
const currentPath = Astro.url.pathname;
|
const currentPath = Astro.url.pathname;
|
||||||
import "../styles/global.css";
|
import "../styles/global.css";
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
title?: string;
|
title?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
ogImage?: string;
|
ogImage?: OpenGraphImage;
|
||||||
ogType?: "website" | "article";
|
ogType?: "website" | "article";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,9 +25,7 @@ const og = config.siteConfig.openGraph;
|
|||||||
const canonicalUrl = new URL(Astro.url.pathname, config.siteConfig.meta.url)
|
const canonicalUrl = new URL(Astro.url.pathname, config.siteConfig.meta.url)
|
||||||
.href;
|
.href;
|
||||||
const resolvedOgImage = ogImage || og.image;
|
const resolvedOgImage = ogImage || og.image;
|
||||||
const resolvedOgImageUrl = resolvedOgImage
|
const resolvedOgImageUrl = new URL(resolvedOgImage.url, config.siteConfig.meta.url).href;
|
||||||
? new URL(resolvedOgImage, config.siteConfig.meta.url).href
|
|
||||||
: undefined;
|
|
||||||
const resolvedOgType = ogType || og.type || "website";
|
const resolvedOgType = ogType || og.type || "website";
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -48,11 +47,11 @@ const resolvedOgType = ogType || og.type || "website";
|
|||||||
<meta property="og:url" content={canonicalUrl} />
|
<meta property="og:url" content={canonicalUrl} />
|
||||||
{og.siteName && <meta property="og:site_name" content={og.siteName} />}
|
{og.siteName && <meta property="og:site_name" content={og.siteName} />}
|
||||||
{og.locale && <meta property="og:locale" content={og.locale} />}
|
{og.locale && <meta property="og:locale" content={og.locale} />}
|
||||||
{
|
|
||||||
resolvedOgImageUrl && (
|
|
||||||
<meta property="og:image" content={resolvedOgImageUrl} />
|
<meta property="og:image" content={resolvedOgImageUrl} />
|
||||||
)
|
<meta property="og:image:width" content={String(resolvedOgImage.width)} />
|
||||||
}
|
<meta property="og:image:height" content={String(resolvedOgImage.height)} />
|
||||||
|
<meta property="og:image:type" content={resolvedOgImage.type} />
|
||||||
|
<meta property="og:image:alt" content={resolvedOgImage.alt} />
|
||||||
|
|
||||||
<ClientRouter />
|
<ClientRouter />
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
12
src/types.ts
12
src/types.ts
@@ -169,8 +169,16 @@ export interface HomepageSections {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface OpenGraphImage {
|
||||||
|
url: string;
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
type: string;
|
||||||
|
alt: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface OpenGraphConfig {
|
export interface OpenGraphConfig {
|
||||||
image?: string;
|
image: OpenGraphImage;
|
||||||
type?: "website" | "article";
|
type?: "website" | "article";
|
||||||
locale?: string;
|
locale?: string;
|
||||||
siteName?: string;
|
siteName?: string;
|
||||||
@@ -179,7 +187,7 @@ export interface OpenGraphConfig {
|
|||||||
export interface PageOpenGraph {
|
export interface PageOpenGraph {
|
||||||
title?: string;
|
title?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
image?: string;
|
image?: OpenGraphImage;
|
||||||
type?: "website" | "article";
|
type?: "website" | "article";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user