feat: trying to add hashes to scripts
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Handlers, PageProps } from "$fresh/server.ts";
|
||||
import { PageProps } from "fresh";
|
||||
import { IngredientsList } from "@islands/IngredientsList.tsx";
|
||||
import { MainLayout } from "@components/layouts/main.tsx";
|
||||
import Counter from "@islands/Counter.tsx";
|
||||
@@ -14,24 +14,24 @@ import { fetchResource } from "@lib/marka/index.ts";
|
||||
import { RecipeResource } from "@lib/marka/schema.ts";
|
||||
import { parseIngredients } from "@lib/parseIngredient.ts";
|
||||
import { parseRating } from "@lib/helpers.ts";
|
||||
import { HttpError } from "fresh";
|
||||
import { define } from "../../utils.ts";
|
||||
|
||||
export const handler: Handlers<
|
||||
{ recipe: RecipeResource; session: unknown } | null
|
||||
> = {
|
||||
async GET(_, ctx) {
|
||||
export const handler = define.handlers({
|
||||
async GET(ctx) {
|
||||
try {
|
||||
const recipe = await fetchResource<RecipeResource>(
|
||||
`recipes/${ctx.params.name}.md`,
|
||||
);
|
||||
if (!recipe) {
|
||||
return ctx.renderNotFound();
|
||||
throw new HttpError(404);
|
||||
}
|
||||
return ctx.render({ recipe, session: ctx.state.session });
|
||||
return { data: { recipe, session: ctx.state.session } };
|
||||
} catch (_e) {
|
||||
return ctx.renderNotFound();
|
||||
throw new HttpError(404);
|
||||
}
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
function ValidRecipe({
|
||||
recipe,
|
||||
@@ -48,11 +48,13 @@ function ValidRecipe({
|
||||
<h3 class="text-3xl my-5">Ingredients</h3>
|
||||
{portion && <Counter count={amount} />}
|
||||
</div>
|
||||
<IngredientsList
|
||||
ingredients={ingredients}
|
||||
amount={amount}
|
||||
portion={portion}
|
||||
/>
|
||||
{
|
||||
<IngredientsList
|
||||
ingredients={ingredients}
|
||||
amount={amount}
|
||||
portion={portion}
|
||||
/>
|
||||
}
|
||||
<h3 class="text-3xl my-5">Preparation</h3>
|
||||
<div class="pl-2">
|
||||
<ol class="list-decimal grid gap-4">
|
||||
@@ -135,7 +137,7 @@ export default function Page(
|
||||
)
|
||||
: (
|
||||
<div class="whitespace-break-spaces markdown-body">
|
||||
{JSON.stringify(recipe)}
|
||||
{recipe}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user