feat: initial refactor to use marka as backend

This commit is contained in:
Max Richter
2025-10-28 20:15:23 +01:00
parent 0beb3b1071
commit f680b5f832
39 changed files with 245 additions and 1012 deletions

View File

@@ -3,6 +3,7 @@ import { IconBrandYoutube } from "@components/icons.tsx";
import { GenericResource } from "@lib/types.ts";
import { SmallRating } from "@components/Rating.tsx";
import { Link } from "@islands/Link.tsx";
import { parseRating } from "@lib/helpers.ts";
export function Card(
{
@@ -96,20 +97,21 @@ export function Card(
export function ResourceCard(
{ res, sublink = "movies" }: { sublink?: string; res: GenericResource },
) {
const { meta: { image } = {} } = res || {};
const img = res?.content?.image || res?.content?.cover;
const imageUrl = image
? `/api/images?image=${image}&width=200&height=200`
const imageUrl = img
? `/api/images?image=${img}&width=200&height=200`
: "/placeholder.svg";
return (
<Card
title={res.name}
title={res.content?.name || res.content?.itemReviewed?.name || res.content?.headline ||
res?.name}
backgroundColor={res.meta?.average}
rating={res.meta?.rating}
thumbnail={res.meta?.thumbnail}
rating={parseRating(res.content?.reviewRating?.ratingValue)}
thumbnail={res.cover}
image={imageUrl}
link={`/${sublink}/${res.id}`}
link={`/${sublink}/${res.name.replace(/\.md$/g, "")}`}
/>
);
}

View File

@@ -2,13 +2,13 @@ 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`
const imageUrl = resource.content?.image
? `/api/images?image=${resource.content.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
"@type": resource.content?._type, // Converts type to PascalCase
name: resource.name,
description: resource.content || resource.meta?.average || "",
keywords: resource.tags?.join(", ") || "",
@@ -45,14 +45,14 @@ 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`
const imageUrl = resource.content?.image
? `/api/images?image=${resource.content.image}&width=1200`
: "/images/og-image.jpg";
return (
<>
<Head>
<meta property="og:title" content={resource.name} />
<meta property="og:type" content={resource.type} />
<meta property="og:title" content={resource.content?.name} />
<meta property="og:type" content={resource.content?._type} />
<meta
property="og:image"
content={imageUrl}