diff --git a/components/Card.tsx b/components/Card.tsx
index 6eff7b4..b662bca 100644
--- a/components/Card.tsx
+++ b/components/Card.tsx
@@ -1,9 +1,9 @@
import { isYoutubeLink } from "@lib/string.ts";
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";
+import { GenericResource, getNameOfResource } from "@lib/marka/schema.ts";
export function Card(
{
@@ -101,14 +101,16 @@ export function ResourceCard(
? `/api/images?image=${img}&width=200&height=200`
: "/placeholder.svg";
+ const rating = res.content.reviewRating?.ratingValue
+ ? parseRating(res.content.reviewRating.ratingValue)
+ : undefined;
+
return (
diff --git a/components/MetaTags.tsx b/components/MetaTags.tsx
index 1ec5601..b811f16 100644
--- a/components/MetaTags.tsx
+++ b/components/MetaTags.tsx
@@ -1,5 +1,6 @@
-import { GenericResource } from "@lib/types.ts";
import { Head } from "$fresh/runtime.ts";
+import { GenericResource, getNameOfResource } from "@lib/marka/schema.ts";
+import { formatDate } from "@lib/string.ts";
function generateJsonLd(resource: GenericResource): string {
const imageUrl = resource.content?.image
@@ -8,34 +9,34 @@ function generateJsonLd(resource: GenericResource): string {
const baseSchema: Record = {
"@context": "https://schema.org",
- "@type": resource.content?._type, // Converts type to PascalCase
+ "@type": resource.content?._type,
name: resource.name,
- description: resource.content || resource.meta?.average || "",
- keywords: resource.tags?.join(", ") || "",
+ description: resource.content || "",
+ keywords: resource.content.keywords?.join(", ") || "",
image: imageUrl,
};
- if (resource.meta?.author) {
+ if (resource.content?.author) {
baseSchema.author = {
"@type": "Person",
- name: resource.meta.author,
+ name: resource.content.author,
};
}
- if (resource.meta?.date) {
+ if (resource.content?.datePublished) {
try {
- baseSchema.datePublished = new Date(resource.meta.date).toISOString();
+ baseSchema.datePublished = formatDate(
+ new Date(resource.content.datePublished),
+ );
} catch (_) {
// Ignore invalid date
}
}
- if (resource.meta?.rating) {
- baseSchema.aggregateRating = {
- "@type": "AggregateRating",
- ratingValue: resource.meta.rating,
- ratingCount: 1,
- bestRating: 5, // Assuming a scale of 1 to 10
+ if (resource.content?.reviewRating) {
+ baseSchema.reviewRating = {
+ "@type": "Rating",
+ ...resource.content.reviewRating,
};
}
@@ -51,7 +52,7 @@ export function MetaTags({ resource }: { resource: GenericResource }) {
return (
<>
-
+
s && (typeof s === "string" ? s?.length > 1 : true)
).map((s) => {
+ if (!s) return;
if (typeof s === "string") {
- return {s};
+ return {s};
} else {
- return {s.title};
+ return {s.title};
}
})}
diff --git a/components/layouts/main.tsx b/components/layouts/main.tsx
index 6f655db..f7f4884 100644
--- a/components/layouts/main.tsx
+++ b/components/layouts/main.tsx
@@ -1,6 +1,6 @@
import { ComponentChildren } from "preact";
import Search from "@islands/Search.tsx";
-import { GenericResource } from "@lib/types.ts";
+import { GenericResource } from "@lib/marka/schema.ts";
export type Props = {
children: ComponentChildren;
@@ -21,7 +21,7 @@ export const MainLayout = (
if (hasSearch) {
return (
diff --git a/deno.json b/deno.json
index 85a66fb..697a747 100644
--- a/deno.json
+++ b/deno.json
@@ -22,6 +22,7 @@
"@lib": "./lib",
"@lib/": "./lib/",
"@libsql/client": "npm:@libsql/client@^0.14.0",
+ "@openai/openai": "jsr:@openai/openai@^6.7.0",
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.2",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.1",
"@std/http": "jsr:@std/http@^1.0.12",
diff --git a/islands/IngredientsList.tsx b/islands/IngredientsList.tsx
index c7513f1..d267f49 100644
--- a/islands/IngredientsList.tsx
+++ b/islands/IngredientsList.tsx
@@ -9,15 +9,12 @@ function formatAmount(num: number) {
}
function formatUnit(unit: string, amount: number) {
- const unitKey = unit.toLowerCase() as keyof typeof unitsOfMeasure;
+ if (!unit) return "";
+ const unitKey = unit.toLowerCase() as (keyof typeof unitsOfMeasure);
if (unitKey in unitsOfMeasure) {
if (amount > 1 && unitsOfMeasure[unitKey].plural !== undefined) {
return unitsOfMeasure[unitKey].plural;
}
- if (unitKey !== "cup") {
- return unitsOfMeasure[unitKey].short;
- }
-
return unitKey.toString();
} else {
return unit;
@@ -66,9 +63,22 @@ export const IngredientsList: FunctionalComponent<
{ingredients.map((item) => {
- return (
-
- );
+ if ("items" in item) {
+ return item.items.map((ing, i) => {
+ return (
+
+ );
+ });
+ } else {
+ return (
+
+ );
+ }
})}
diff --git a/islands/KMenu.tsx b/islands/KMenu.tsx
index e3ee48b..a55ca5c 100644
--- a/islands/KMenu.tsx
+++ b/islands/KMenu.tsx
@@ -103,8 +103,9 @@ export const KMenu = (
}
useEventListener("keydown", (ev: KeyboardEvent) => {
+ const target = ev.target as HTMLElement;
if (ev.key === "k") {
- if (ev?.target?.nodeName == "INPUT") {
+ if (target.nodeName == "INPUT") {
return;
}
diff --git a/islands/Link.tsx b/islands/Link.tsx
index 014e184..e34f8c5 100644
--- a/islands/Link.tsx
+++ b/islands/Link.tsx
@@ -1,7 +1,6 @@
import { useEffect } from "preact/hooks";
declare global {
- // deno-lint-ignore no-var
var loadingTimeout: ReturnType | undefined;
}
diff --git a/islands/Recommendations.tsx b/islands/Recommendations.tsx
index 7cac972..19b428b 100644
--- a/islands/Recommendations.tsx
+++ b/islands/Recommendations.tsx
@@ -1,5 +1,6 @@
import { useCallback, useState } from "preact/hooks";
import { IconWand } from "@components/icons.tsx";
+import { RecommendationResource } from "@lib/recommendation.ts";
type RecommendationState = "disabled" | "loading";
@@ -11,7 +12,7 @@ export function Recommendations(
},
) {
const [state, setState] = useState("disabled");
- const [results, setResults] = useState();
+ const [results, setResults] = useState();
const startFetch = useCallback(
async () => {
@@ -44,9 +45,9 @@ export function Recommendations(

-
{res.title}
+
{res.id}
);
})}
@@ -66,6 +67,7 @@ export function Recommendations(
{!results && state === "disabled" &&
(