fix: soo many lint errors
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { PageProps, RouteContext } from "$fresh/server.ts";
|
||||
import { MainLayout } from "@components/layouts/main.tsx";
|
||||
import { ReviewResource, ReviewSchema } from "@lib/marka/schema.ts";
|
||||
import { ReviewResource } from "@lib/marka/schema.ts";
|
||||
import { removeImage, renderMarkdown } from "@lib/markdown.ts";
|
||||
import { KMenu } from "@islands/KMenu.tsx";
|
||||
import { RedirectSearchHandler } from "@islands/Search.tsx";
|
||||
@@ -24,12 +24,16 @@ export default async function Greet(
|
||||
return ctx.renderNotFound();
|
||||
}
|
||||
|
||||
const { author = "", datePublished = "", reviewBody } = movie.content;
|
||||
const { author, datePublished, reviewBody = "", reviewRating } =
|
||||
movie.content;
|
||||
|
||||
const content = renderMarkdown(
|
||||
removeImage(reviewBody || "", movie.content.image),
|
||||
removeImage(reviewBody, movie.content.image),
|
||||
);
|
||||
|
||||
const rating = reviewRating?.ratingValue &&
|
||||
parseRating(reviewRating.ratingValue);
|
||||
|
||||
return (
|
||||
<MainLayout url={props.url} title={`Movie > ${movie.name}`} context={movie}>
|
||||
<RedirectSearchHandler />
|
||||
@@ -53,37 +57,33 @@ export default async function Greet(
|
||||
</PageHero.Title>
|
||||
<PageHero.Subline
|
||||
entries={[
|
||||
author && {
|
||||
title: author?.name,
|
||||
author?.name &&
|
||||
{
|
||||
title: author.name,
|
||||
href: `/?q=${encodeURIComponent(author?.name)}`,
|
||||
},
|
||||
datePublished.toString(),
|
||||
datePublished?.toString(),
|
||||
]}
|
||||
>
|
||||
{movie.content.reviewRating && (
|
||||
<Star
|
||||
rating={parseRating(movie.content?.reviewRating?.ratingValue)}
|
||||
/>
|
||||
)}
|
||||
{rating && <Star rating={rating} />}
|
||||
</PageHero.Subline>
|
||||
</PageHero.Footer>
|
||||
</PageHero>
|
||||
{false && (
|
||||
{movie.name && (
|
||||
<Recommendations
|
||||
id={movie.id}
|
||||
id={movie.name}
|
||||
type="movie"
|
||||
/>
|
||||
)}
|
||||
<div class="px-8 text-white mt-10">
|
||||
{movie?.content?.reviewBody?.length > 80
|
||||
? <h2 class="text-4xl font-bold mb-4">Review</h2>
|
||||
: <></>}
|
||||
{reviewBody?.length > 80 && (
|
||||
<h2 class="text-4xl font-bold mb-4">Review</h2>
|
||||
)}
|
||||
<pre
|
||||
class="whitespace-break-spaces"
|
||||
// deno-lint-ignore react-no-danger
|
||||
dangerouslySetInnerHTML={{ __html: content || "" }}
|
||||
>
|
||||
{content}
|
||||
</pre>
|
||||
/>
|
||||
</div>
|
||||
</MainLayout>
|
||||
);
|
||||
|
||||
@@ -1,29 +1,33 @@
|
||||
import { MainLayout } from "@components/layouts/main.tsx";
|
||||
import { ReviewResource } from "@lib/marka/schema.ts";
|
||||
import { GenericResource, ReviewResource } from "@lib/marka/schema.ts";
|
||||
import { ResourceCard } from "@components/Card.tsx";
|
||||
import { Grid } from "@components/Grid.tsx";
|
||||
import { IconArrowLeft } from "@components/icons.tsx";
|
||||
import { KMenu } from "@islands/KMenu.tsx";
|
||||
import { RedirectSearchHandler } from "@islands/Search.tsx";
|
||||
import { GenericResource } from "@lib/types.ts";
|
||||
import { PageProps } from "$fresh/server.ts";
|
||||
import { listResources } from "@lib/marka/index.ts";
|
||||
import { parseResourceUrl, searchResource } from "@lib/search.ts";
|
||||
import { parseRating } from "@lib/helpers.ts";
|
||||
|
||||
function sortOptional(a: number | string = 0, b: number | string = 0) {
|
||||
return (parseRating(a) > parseRating(b)) ? 1 : -1;
|
||||
}
|
||||
|
||||
export default async function MovieIndex(
|
||||
props: PageProps<
|
||||
{ movies: ReviewResource[] | null; searchResults: GenericResource[] }
|
||||
>,
|
||||
) {
|
||||
const allMovies = await listResources("movies");
|
||||
const allMovies = await listResources<ReviewResource>("movies");
|
||||
const searchParams = parseResourceUrl(props.url);
|
||||
const searchResults = searchParams &&
|
||||
await searchResource({ ...searchParams, types: ["movie"] });
|
||||
const movies = allMovies.sort((a, b) =>
|
||||
a?.content?.reviewRating?.ratingValue >
|
||||
b?.content?.reviewRating?.ratingValue
|
||||
? -1
|
||||
: 1
|
||||
sortOptional(
|
||||
a.content.reviewRating?.ratingValue,
|
||||
b.content.reviewRating?.ratingValue,
|
||||
)
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user