This commit is contained in:
@@ -26,13 +26,13 @@ export async function getStaticPaths() {
|
||||
);
|
||||
|
||||
return paths.flat().filter(Boolean);
|
||||
}catch(err){
|
||||
return []
|
||||
} catch (err) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
const resource = await memorium.listResource(
|
||||
`/${resourceType}/${resourceName}.md`,
|
||||
`${resourceType}/${resourceName}.md`,
|
||||
);
|
||||
---
|
||||
|
||||
@@ -59,7 +59,7 @@ const resource = await memorium.listResource(
|
||||
<h2>Ingredients</h2>
|
||||
<ul>
|
||||
{
|
||||
resource.content.recipeIngredient.map((ingredient) => (
|
||||
resource?.content.recipeIngredient.map((ingredient) => (
|
||||
<li>{markdownToText(ingredient)}</li>
|
||||
))
|
||||
}
|
||||
@@ -68,7 +68,7 @@ const resource = await memorium.listResource(
|
||||
<h2>Steps</h2>
|
||||
<ol>
|
||||
{
|
||||
resource.content.recipeInstructions.map((ingredient) => (
|
||||
resource?.content.recipeInstructions.map((ingredient) => (
|
||||
<li>{markdownToText(ingredient)}</li>
|
||||
))
|
||||
}
|
||||
|
||||
@@ -6,7 +6,15 @@ import { resources as resourceTypes } from "../resources.ts";
|
||||
|
||||
const { resourceType } = Astro.params;
|
||||
|
||||
const resources = await memorium.listResource(resourceType);
|
||||
async function safeGetResource(resType) {
|
||||
try {
|
||||
return await memorium.listResource(resourceType);
|
||||
} catch (error) {
|
||||
return {content:[]};
|
||||
}
|
||||
}
|
||||
|
||||
const resources = await safeGetResource(resourceType);
|
||||
|
||||
export async function getStaticPaths() {
|
||||
return resourceTypes.map((type: any) => {
|
||||
|
||||
@@ -3,7 +3,6 @@ const collection = "resources";
|
||||
type Resource = {
|
||||
id: string;
|
||||
collection: string;
|
||||
body: string;
|
||||
data: {
|
||||
title: string;
|
||||
icon: string;
|
||||
@@ -31,9 +30,8 @@ type Resource = {
|
||||
// };
|
||||
|
||||
const recipes = {
|
||||
id: "Recipes",
|
||||
id: "recipes",
|
||||
collection,
|
||||
body: "Recipes",
|
||||
data: {
|
||||
title: "Recipes",
|
||||
icon: "🍲",
|
||||
|
||||
Reference in New Issue
Block a user