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,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}