feat: store image metadata in sqlite and images on disk

This commit is contained in:
2025-01-05 21:27:31 +01:00
parent bf7d88a588
commit 20a2781214
18 changed files with 641 additions and 379 deletions

View File

@ -1,7 +1,7 @@
import { isLocalImage, isYoutubeLink } from "@lib/string.ts";
import { isYoutubeLink } from "@lib/string.ts";
import { IconBrandYoutube } from "@components/icons.tsx";
import { GenericResource } from "@lib/types.ts";
import { Rating, SmallRating } from "@components/Rating.tsx";
import { SmallRating } from "@components/Rating.tsx";
export function Card(
{
@ -95,11 +95,11 @@ export function Card(
export function ResourceCard(
{ res, sublink = "movies" }: { sublink?: string; res: GenericResource },
) {
const { meta: { image = "/placeholder.svg" } = {} } = res;
const { meta: { image } = {} } = res;
const imageUrl = isLocalImage(image)
const imageUrl = image
? `/api/images?image=${image}&width=200&height=200`
: image;
: "/placeholder.svg";
return (
<Card

View File

@ -1,6 +1,5 @@
import { asset } from "$fresh/runtime.ts";
import * as CSS from "https://esm.sh/csstype@3.1.2";
import { isLocalImage } from "@lib/string.ts";
interface ResponsiveAttributes {
srcset: string;
@ -42,9 +41,11 @@ const Image = (
style?: CSS.HtmlAttributes;
},
) => {
const responsiveAttributes: ResponsiveAttributes = isLocalImage(props.src)
? generateResponsiveAttributes(props.src, widths, "/api/images")
: { srcset: "", sizes: "" };
const responsiveAttributes = generateResponsiveAttributes(
props.src,
widths,
"/api/images",
);
return (
<span
@ -64,7 +65,7 @@ const Image = (
style={props.style}
srcset={responsiveAttributes.srcset}
sizes={responsiveAttributes.sizes}
src={asset(props.src)}
src={`/api/images?image=${asset(props.src)}`}
width={props.width}
height={props.height}
class={props.class}

View File

@ -5,7 +5,6 @@ import { type ComponentChildren, createContext } from "preact";
import { IconArrowNarrowLeft } from "@components/icons.tsx";
import { IconEdit } from "@components/icons.tsx";
import { useContext } from "preact/hooks";
import { GenericResource } from "@lib/types.ts";
const HeroContext = createContext<{ image?: string; thumbnail?: string }>({
image: undefined,