Signed-off-by: Max Schmidt <max.schmidt@outlook.de>
This commit is contained in:
Max Schmidt 2023-05-19 08:05:10 +02:00
parent b958e29288
commit a3e58fecd6
2 changed files with 4 additions and 1 deletions

View File

@ -1,6 +1,7 @@
--- ---
import { Image } from "@astrojs/image/components"; import { Image } from "@astrojs/image/components";
import { getContentArray } from "../utils/helpers"; import { getContentArray } from "../utils/helpers";
import { getImageSrc } from "../utils/payload";
const { content } = Astro.props; const { content } = Astro.props;
const contentArray = getContentArray(content); const contentArray = getContentArray(content);
--- ---
@ -13,7 +14,7 @@ const contentArray = getContentArray(content);
} else { } else {
return ( return (
<Image <Image
src={`http://payload:3001/media/${value.src}`} src={getImageSrc(value.src)}
width={value.width} width={value.width}
height={value.height} height={value.height}
format="webp" format="webp"

View File

@ -9,3 +9,5 @@ export const getPosts = async () =>
export const getPost = async (id: string) => export const getPost = async (id: string) =>
(await (await fetch(`${url}/api/posts/${id}`)).json()) as Post; (await (await fetch(`${url}/api/posts/${id}`)).json()) as Post;
export const getImageSrc = (src: string) => `${url}/media/${src}}`;