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