mirror of
https://github.com/catdevnull/preciazo.git
synced 2025-02-20 01:06:25 +00:00
product preview en index
This commit is contained in:
parent
f20203cac8
commit
d59b4283bc
2 changed files with 8 additions and 5 deletions
|
@ -6,7 +6,11 @@ import { sql } from "drizzle-orm";
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ params }) => {
|
export const load: PageServerLoad = async ({ params }) => {
|
||||||
const q = db
|
const q = db
|
||||||
.select({ ean: precios.ean, name: precios.name })
|
.select({
|
||||||
|
ean: precios.ean,
|
||||||
|
name: precios.name,
|
||||||
|
imageUrl: precios.imageUrl,
|
||||||
|
})
|
||||||
.from(precios)
|
.from(precios)
|
||||||
.groupBy(precios.ean)
|
.groupBy(precios.ean)
|
||||||
.having(sql`max(length(name))`)
|
.having(sql`max(length(name))`)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import ProductPreview from "$lib/ProductPreview.svelte";
|
||||||
import type { PageData } from "./$types";
|
import type { PageData } from "./$types";
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
@ -30,12 +31,10 @@
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<h2 class="text-lg font-bold">Random</h2>
|
<h2 class="text-lg font-bold">Random</h2>
|
||||||
<ul>
|
<ul class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||||
{#each data.precios as product}
|
{#each data.precios as product}
|
||||||
<li>
|
<li>
|
||||||
<a href={`/ean/${product.ean}`}>
|
<ProductPreview {product} />
|
||||||
{product.name}
|
|
||||||
</a>
|
|
||||||
</li>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in a new issue