Compare commits

...

4 Commits

Author SHA1 Message Date
a266e7fb3a Add proper titles to pages 2025-12-04 09:15:02 +13:00
85273f163c decent search page which should be everything!! 2025-11-19 21:46:33 +13:00
27dc6b6fb9 no, but maaaaaybe now?? 2025-11-19 21:19:07 +13:00
cb86dec266 Did that just fix compose? 2025-11-19 16:52:53 +13:00
9 changed files with 106 additions and 19 deletions

View File

@@ -1,6 +1,10 @@
services:
web:
build: web
build:
context: web
args:
- PB_EMAIL=${PB_EMAIL}
- PB_PW=${PB_PW}
env_file: .env
ports:
- "4321:4321"
@@ -15,3 +19,5 @@ services:
ports:
- "8090:8090"
networks:
recipie:

View File

@@ -6,6 +6,11 @@ COPY . .
ENV PUBLIC_PB_URL="http://pb:8090"
ENV PUBLIC_URL=http://localhost:4321
ARG PB_EMAIL
ARG PB_PW
ENV PB_EMAIL=$PB_EMAIL
ENV PB_PW=$PB_PW
RUN npm run build
EXPOSE 4321

View File

@@ -1,9 +0,0 @@
---
import "../styles/global.css"
---
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<title>Astro</title>

View File

@@ -4,10 +4,10 @@ const links = [
txt: "new",
lnk: "/recipe/new"
},
{
txt: "add",
lnk: "/recipe/import"
},
// {
// txt: "add",
// lnk: "/recipe/import"
// },
{
txt: "tags",
lnk: "/tags"

View File

@@ -1,12 +1,19 @@
---
import BaseHead from '@component/BaseHead'
import Header from '@component/Header'
import "../styles/global.css";
const {
title
} = Astro.props
---
<html lang=en>
<head>
<BaseHead title="Recipie" />
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<title>{title ? title : "Recipie"}</title>
</head>
<body>
<main id="main" class="flex-1">

View File

@@ -53,7 +53,7 @@ const recipeId = id as string
});
</script>
<Base>
<Base title="Edit Recipe">
<div class="flex flex-col md:flex-row mx-auto justify-center w-full lg:max-w-3/4 xl:max-w-2/3 2xl:max-w-1/2">
<div class="flex md:flex-1/3 flex-col sticky">

View File

@@ -20,7 +20,7 @@ const images = await Promise.all(
)
---
<Base>
<Base title=`${recipeData.metadata.title}: Recipie` >
<div class="flex flex-col md:flex-row mx-auto justify-center w-full lg:max-w-3/4 xl:max-w-2/3 2xl:max-w-1/2">
<div class="flex md:flex-1/3 flex-col mt-2 md:mt-4 sticky">
<ImageCarousel class="w-full" images={images} />

View File

@@ -57,7 +57,7 @@ tags:
});
</script>
<Base>
<Base title="New Recipe">
<div class="flex flex-col md:flex-row mx-auto justify-center w-full lg:max-w-3/4 xl:max-w-2/3 2xl:max-w-1/2">
<div class="flex md:flex-1/3 flex-col sticky">

View File

@@ -0,0 +1,78 @@
---
import { Recipe } from "@tmlmt/cooklang-parser"
import { authPB } from "@data/pb";
import RecipeCard from "@component/index/card"
import Base from "@layout/Base";
const pb = await authPB()
// Get search query from URL
const url = new URL(Astro.request.url);
const query = url.searchParams.get('q') || '';
let recipes: Recipe[] = [];
let ids: string[] = [];
let images: string[] = [];
let totalResults = 0;
if (query) {
// Search in title, description, and cooklang content
const result = await pb.collection('recipes').getList(1, 50, {
filter: `cooklang ~ "${query}"`
});
totalResults = result.totalItems;
recipes = result.items.map((r: any) => new Recipe(r.cooklang));
ids = result.items.map((r: any) => r.id);
images = await Promise.all(
result.items.map((r: any) => '/api' + pb.files.getURL(r, r.images[0]).split('api')[1])
);
}
---
<Base title=`Search${ query != "" ? ": " + query : "" }`>
<div class="mb-6">
<!-- <h1 class="text-3xl font-bold mb-4">Search Recipes</h1> -->
<form method="get" class="my-6">
<div class="flex gap-2">
<input
type="text"
name="q"
value={query}
placeholder="Search recipes..."
class="flex-1 px-4 py-2 rounded-lg bg-[#2a2b2c] text-white border border-gray-600 focus:outline-none focus:border-gray-500"
autofocus
/>
<button
type="submit"
class="px-6 py-2 bg-gray-200/20 hover:bg-gray-200/30 rounded-lg font-semibold transition-colors"
>
Search
</button>
</div>
</form>
{query && (
<p class="text-gray-400">
{totalResults} result{totalResults !== 1 ? 's' : ''} for "{query}"
</p>
)}
</div>
{query && recipes.length > 0 && (
<div class="grid gap-3 grid-cols-1 py-3 md:grid-cols-2 lg:grid-cols-4 xl:grid-cols-6">
{
recipes.map((r, i) => (
<RecipeCard
id={ids[i]}
title={r.metadata.title ?? "Untitled Recipe"}
description={r.metadata.description ?? "No Description"}
tags={r.metadata.tags ?? []}
image={images[i]}
/>
))
}
</div>
)}
</Base>