fix: soo many lint errors
This commit is contained in:
@@ -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 (
|
||||
<Card
|
||||
title={res.content?.name || res.content?.itemReviewed?.name ||
|
||||
res.content?.headline ||
|
||||
res?.name}
|
||||
title={getNameOfResource(res)}
|
||||
backgroundColor={res.image?.average}
|
||||
thumbhash={res.image?.blurhash}
|
||||
rating={parseRating(res.content?.reviewRating?.ratingValue)}
|
||||
thumbhash={res.image?.thumbhash}
|
||||
rating={rating}
|
||||
image={imageUrl}
|
||||
link={`/${sublink}/${res.name.replace(/\.md$/g, "")}`}
|
||||
/>
|
||||
|
||||
@@ -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<string, unknown> = {
|
||||
"@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 (
|
||||
<>
|
||||
<Head>
|
||||
<meta property="og:title" content={resource.content?.name} />
|
||||
<meta property="og:title" content={getNameOfResource(resource)} />
|
||||
<meta property="og:type" content={resource.content?._type} />
|
||||
<meta
|
||||
property="og:image"
|
||||
|
||||
@@ -104,7 +104,7 @@ function Header({ children }: { children: ComponentChildren }) {
|
||||
function Subline(
|
||||
{ entries, children }: {
|
||||
children?: ComponentChildren;
|
||||
entries: (string | { href: string; title: string })[];
|
||||
entries: (string | undefined | { href: string; title: string })[];
|
||||
},
|
||||
) {
|
||||
const ctx = useContext(HeroContext);
|
||||
@@ -117,10 +117,11 @@ function Subline(
|
||||
{entries.filter((s) =>
|
||||
s && (typeof s === "string" ? s?.length > 1 : true)
|
||||
).map((s) => {
|
||||
if (!s) return;
|
||||
if (typeof s === "string") {
|
||||
return <span>{s}</span>;
|
||||
return <span key={s}>{s}</span>;
|
||||
} else {
|
||||
return <a href={s.href}>{s.title}</a>;
|
||||
return <a key={s.href} href={s.href}>{s.title}</a>;
|
||||
}
|
||||
})}
|
||||
</div>
|
||||
|
||||
@@ -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 (
|
||||
<Search
|
||||
q={_url.searchParams.get("q")}
|
||||
q={_url.searchParams.get("q") || ""}
|
||||
{...context}
|
||||
results={searchResults}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user