fix: some stuff
All checks were successful
Deploy to SFTP Server / build (push) Successful in 24m33s
All checks were successful
Deploy to SFTP Server / build (push) Successful in 24m33s
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
---
|
||||
import type { ImageMetadata } from "astro";
|
||||
import { Picture as AstroImage } from "astro:assets";
|
||||
import { inferRemoteSize, inferSize } from "astro/assets/utils";
|
||||
import { inferRemoteSize } from "astro/assets/utils";
|
||||
import { getProcessedImage } from "@helpers/image";
|
||||
interface Props {
|
||||
src: ImageMetadata & { fsPath?: string; src?: string };
|
||||
@@ -21,7 +21,7 @@ async function checkImage(
|
||||
const src = typeof image === "string" ? image : image.src;
|
||||
if (!src) return;
|
||||
try {
|
||||
if (src.startsWith("/@fs") || src.startsWith("/_astro")) return {};
|
||||
if (src.startsWith("/@fs") || src.startsWith("/_astro")) return image;
|
||||
const res = await inferRemoteSize(src);
|
||||
if (res.format) {
|
||||
image.format = res.format;
|
||||
|
||||
@@ -3,7 +3,7 @@ import Layout from "@layouts/Layout.astro";
|
||||
import { useTranslatedPath } from "@i18n/utils";
|
||||
import ResourceDisplay from "@components/resources/Display.astro";
|
||||
import * as memorium from "@helpers/memorium";
|
||||
import { resources as resourceTypes } from "../resources.ts";
|
||||
import { resources as resourceTypes } from "@content/resources.ts";
|
||||
|
||||
const { resourceType, resourceName } = Astro?.params;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import HeroCard from "@components/HeroCard.astro";
|
||||
import * as memorium from "@helpers/memorium";
|
||||
import { resources as resourceTypes } from "../resources.ts";
|
||||
import { resources as resourceTypes } from "@content/resources.ts";
|
||||
import { useTranslations } from "@i18n/utils";
|
||||
import ClientSearch from "@components/ClientSearch.svelte";
|
||||
|
||||
@@ -34,15 +34,19 @@ function isValidResource(res: any) {
|
||||
return !!res?.content?._type;
|
||||
}
|
||||
|
||||
function buildSearchTerm(res:any){
|
||||
if(!res) return "";
|
||||
return Object.keys(res).map((key) => {
|
||||
if(key.startsWith("_")) return;
|
||||
const value = res[key];
|
||||
if(Array.isArray(value)) return value.join(" ");
|
||||
if(typeof value === "object") return buildSearchTerm(value);
|
||||
return value
|
||||
}).filter(s => !!s?.length).join(" ").toLowerCase();
|
||||
function buildSearchTerm(res: any) {
|
||||
if (!res) return "";
|
||||
return Object.keys(res)
|
||||
.map((key) => {
|
||||
if (key.startsWith("_")) return;
|
||||
const value = res[key];
|
||||
if (Array.isArray(value)) return value.join(" ");
|
||||
if (typeof value === "object") return buildSearchTerm(value);
|
||||
return value;
|
||||
})
|
||||
.filter((s) => !!s?.length)
|
||||
.join(" ")
|
||||
.toLowerCase();
|
||||
}
|
||||
---
|
||||
|
||||
@@ -52,7 +56,7 @@ function buildSearchTerm(res:any){
|
||||
|
||||
<ClientSearch resourceType={resourceType} client:load />
|
||||
|
||||
<div id="resource-list-static"class="flex flex-col gap-6">
|
||||
<div id="resource-list-static" class="flex flex-col gap-6">
|
||||
{
|
||||
resources?.content
|
||||
.filter((res: any) => isValidResource(res))
|
||||
|
||||
@@ -1,49 +1,54 @@
|
||||
---
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import HeroCard from "@components/HeroCard.astro";
|
||||
import { resources } from "./resources.ts";
|
||||
import { resources } from "@content/resources.ts";
|
||||
import { useTranslations } from "@i18n/utils";
|
||||
import * as memorium from "@helpers/memorium";
|
||||
|
||||
const t = useTranslations(Astro.url);
|
||||
|
||||
async function getCoverImage(resourceName:string){
|
||||
async function getCoverImage(resourceName: string) {
|
||||
const resources = await memorium.listResource(resourceName);
|
||||
if(!resources?.content) return "";
|
||||
if (!resources?.content) return "";
|
||||
let amount = 0;
|
||||
while (true){
|
||||
while (true) {
|
||||
amount++;
|
||||
const randomResource = resources?.content[Math.floor(Math.random() * resources?.content.length)];
|
||||
const cover = randomResource?.content?.cover || randomResource?.content?.image;
|
||||
if(cover){
|
||||
if(cover.startsWith("https://") || cover.startsWith("http://")){
|
||||
const randomResource =
|
||||
resources?.content[Math.floor(Math.random() * resources?.content.length)];
|
||||
const cover =
|
||||
randomResource?.content?.cover || randomResource?.content?.image;
|
||||
if (cover) {
|
||||
if (cover.startsWith("https://") || cover.startsWith("http://")) {
|
||||
continue;
|
||||
}
|
||||
return `https://marka.max-richter.dev/${cover}`;
|
||||
}
|
||||
if(amount > 50) {
|
||||
if (amount > 50) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
<Layout title="Max Richter">
|
||||
{
|
||||
await Promise.all(resources.map(async (resource) => {
|
||||
const cover = await getCoverImage(resource.id);
|
||||
console.log({cover})
|
||||
return <HeroCard
|
||||
post={{
|
||||
...resource,
|
||||
body: t(`${resource.id}.description`),
|
||||
data: {
|
||||
cover: { src: cover },
|
||||
title: t(resource.id),
|
||||
},
|
||||
}}
|
||||
/>
|
||||
}))
|
||||
await Promise.all(
|
||||
resources.map(async (resource) => {
|
||||
const cover = await getCoverImage(resource.id);
|
||||
console.log({ cover });
|
||||
return (
|
||||
<HeroCard
|
||||
post={{
|
||||
...resource,
|
||||
body: t(`${resource.id}.description`),
|
||||
data: {
|
||||
cover: { src: cover },
|
||||
title: t(resource.id),
|
||||
},
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}),
|
||||
)
|
||||
}
|
||||
</Layout>
|
||||
|
||||
Reference in New Issue
Block a user