This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
---
|
||||
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 markdownToText from "@helpers/markdownToText";
|
||||
import { markdownToText } from "@helpers/markdown";
|
||||
import Image from "@components/Image.astro";
|
||||
|
||||
const { resourceType, resourceName } = Astro?.params;
|
||||
@@ -35,9 +36,6 @@ export async function getStaticPaths() {
|
||||
const resource = await memorium.listResource(
|
||||
`${resourceType}/${resourceName}.md`,
|
||||
);
|
||||
|
||||
const ingredients = resource?.content?.recipeIngredient || [];
|
||||
const instructions = resource?.content?.recipeInstructions || [];
|
||||
---
|
||||
|
||||
<Layout title="Max Richter">
|
||||
@@ -49,7 +47,7 @@ const instructions = resource?.content?.recipeInstructions || [];
|
||||
</a>
|
||||
<div class="date opacity-50">
|
||||
{
|
||||
resource?.content.date?.toLocaleString("en-US", {
|
||||
resource?.content.datePublished?.toLocaleString("en-US", {
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
year: "numeric",
|
||||
@@ -57,28 +55,5 @@ const instructions = resource?.content?.recipeInstructions || [];
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <pre>{JSON.stringify(resource, null, 2)}</pre> -->
|
||||
<h1 class="text-4xl">{resource?.content?.name}</h1>
|
||||
<div>
|
||||
{resource?.content?.image && <Image hash src={{src: memorium.getImageUrl(resource.content.image)}} alt="Cover for {resource?.content?.name}" class="rounded-2xl overflow-hidden" pictureClass="rounded-2xl" />}
|
||||
</div>
|
||||
<p>{resource?.content?.description}</p>
|
||||
<h2 class="text-2xl">Ingredients</h2>
|
||||
<ul>
|
||||
{
|
||||
ingredients.map((ingredient) => (
|
||||
<li>{markdownToText(ingredient)}</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
|
||||
<h2 class="text-2xl">Steps</h2>
|
||||
<ol>
|
||||
{
|
||||
instructions.map((ingredient) => (
|
||||
<li>{markdownToText(ingredient)}</li>
|
||||
))
|
||||
}
|
||||
</ol>
|
||||
<ResourceDisplay resource={resource} />
|
||||
</Layout>
|
||||
|
||||
@@ -3,7 +3,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 markdownToText from "@helpers/markdownToText";
|
||||
import { markdownToText } from "@helpers/markdown";
|
||||
|
||||
const { resourceType } = Astro.params;
|
||||
|
||||
@@ -28,19 +28,25 @@ export async function getStaticPaths() {
|
||||
});
|
||||
}
|
||||
|
||||
function isValidResource(res) {
|
||||
if (res?.content?.name) return true;
|
||||
if (res?.content?.headline) return true;
|
||||
return false;
|
||||
}
|
||||
---
|
||||
|
||||
<Layout title="Max Richter">
|
||||
{
|
||||
resources.content
|
||||
.filter((res) => res && res?.content && res?.content?.name)
|
||||
.filter((res) => res && res?.content)
|
||||
.map((resource: any) => (
|
||||
<HeroCard
|
||||
post={{
|
||||
collection: "resources/" + resourceType,
|
||||
id: resource.name.replace(/\.md$/, ""),
|
||||
data: {
|
||||
title: resource.content.name,
|
||||
title: resource.content.name ?? resource.content.headline,
|
||||
date: resource?.content?.datePublished,
|
||||
cover: {
|
||||
src: memorium.getImageUrl(resource.content.image),
|
||||
},
|
||||
@@ -50,3 +56,4 @@ export async function getStaticPaths() {
|
||||
))
|
||||
}
|
||||
</Layout>
|
||||
</Layout>
|
||||
|
||||
@@ -19,15 +19,14 @@ type Resource = {
|
||||
// },
|
||||
// };
|
||||
|
||||
// const articles = {
|
||||
// id: "Articles",
|
||||
// collection,
|
||||
// body: "Articles saved",
|
||||
// data: {
|
||||
// title: "Articles",
|
||||
// icon: "📰",
|
||||
// },
|
||||
// };
|
||||
const articles = {
|
||||
id: "articles",
|
||||
collection,
|
||||
data: {
|
||||
title: "Articles",
|
||||
icon: "📰",
|
||||
},
|
||||
};
|
||||
|
||||
const recipes = {
|
||||
id: "recipes",
|
||||
@@ -58,4 +57,4 @@ const recipes = {
|
||||
// },
|
||||
// };
|
||||
|
||||
export const resources: Resource[] = [recipes];
|
||||
export const resources: Resource[] = [recipes, articles];
|
||||
|
||||
Reference in New Issue
Block a user