fix: use correct image links
This commit is contained in:
parent
a2b5b6cba7
commit
8d13165ff3
@ -2,16 +2,17 @@ import { GenericResource } from "@lib/types.ts";
|
||||
import { Head } from "$fresh/runtime.ts";
|
||||
|
||||
function generateJsonLd(resource: GenericResource): string {
|
||||
const imageUrl = resource.meta?.image
|
||||
? `/api/images?image=${resource.meta.image}&width=1200`
|
||||
: "/images/og-image.jpg";
|
||||
|
||||
const baseSchema: Record<string, unknown> = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": resource.type.charAt(0).toUpperCase() + resource.type.slice(1), // Converts type to PascalCase
|
||||
name: resource.name,
|
||||
description: resource.content || resource.meta?.average || "",
|
||||
keywords: resource.tags?.join(", ") || "",
|
||||
image: `/${resource.meta?.image || "/images/og-image.jpg"}`.replace(
|
||||
"//",
|
||||
"/",
|
||||
),
|
||||
image: imageUrl,
|
||||
};
|
||||
|
||||
if (resource.meta?.author) {
|
||||
@ -38,6 +39,10 @@ function generateJsonLd(resource: GenericResource): string {
|
||||
|
||||
export function MetaTags({ resource }: { resource: GenericResource }) {
|
||||
const jsonLd = generateJsonLd(resource);
|
||||
|
||||
const imageUrl = resource.meta?.image
|
||||
? `/api/images?image=${resource.meta.image}&width=1200`
|
||||
: "/images/og-image.jpg";
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
@ -45,10 +50,7 @@ export function MetaTags({ resource }: { resource: GenericResource }) {
|
||||
<meta property="og:type" content={resource.type} />
|
||||
<meta
|
||||
property="og:image"
|
||||
content={`/${resource.meta?.image || "/images/og-image.jpg"}`.replace(
|
||||
"//",
|
||||
"/",
|
||||
)}
|
||||
content={imageUrl}
|
||||
/>
|
||||
<script
|
||||
type="application/ld+json"
|
||||
|
Loading…
x
Reference in New Issue
Block a user