This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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={{
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user