feat: display articles
Some checks failed
Deploy to SFTP Server / build (push) Failing after 3m59s

This commit is contained in:
Max Richter
2025-10-22 17:43:04 +02:00
parent ae266dbdc5
commit 342f83c783
7 changed files with 14 additions and 18 deletions

View File

@@ -4,8 +4,6 @@ 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 { markdownToText } from "@helpers/markdown";
import Image from "@components/Image.astro";
const { resourceType, resourceName } = Astro?.params;

View File

@@ -3,11 +3,10 @@ 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 { markdownToText } from "@helpers/markdown";
const { resourceType } = Astro.params;
async function safeGetResource(resType) {
async function safeGetResource() {
try {
return await memorium.listResource(resourceType);
} catch (error) {
@@ -15,7 +14,7 @@ async function safeGetResource(resType) {
}
}
const resources = await safeGetResource(resourceType);
const resources = await safeGetResource();
export async function getStaticPaths() {
return resourceTypes.map((type: any) => {
@@ -29,6 +28,7 @@ export async function getStaticPaths() {
}
function isValidResource(res) {
if(!res.content) return false;
if (res?.content?.name) return true;
if (res?.content?.headline) return true;
return false;
@@ -38,7 +38,7 @@ function isValidResource(res) {
<Layout title="Max Richter">
{
resources.content
.filter((res) => res && res?.content)
.filter((res) => isValidResource(res))
.map((resource: any) => (
<HeroCard
post={{

View File

@@ -1,6 +1,6 @@
const collection = "resources";
type Resource = {
export type ResourceType = {
id: string;
collection: string;
data: {
@@ -57,4 +57,4 @@ const recipes = {
// },
// };
export const resources: Resource[] = [recipes, articles];
export const resources: ResourceType[] = [recipes, articles];