diff --git a/db/seed.ts b/db/seed.ts index d1a52c1..cbe0c59 100644 --- a/db/seed.ts +++ b/db/seed.ts @@ -1,4 +1,5 @@ import { Note, db } from "astro:db"; +import dayjs from "dayjs"; // https://astro.build/db/seed export default async function seed() { @@ -8,7 +9,7 @@ export default async function seed() { { content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.", - published: new Date(), + published: 0, }, ]); } diff --git a/src/pages/notes/[slug].astro b/src/pages/notes/[slug].astro index 2a15bc0..f1e785b 100644 --- a/src/pages/notes/[slug].astro +++ b/src/pages/notes/[slug].astro @@ -1,17 +1,19 @@ --- -import { eq } from "astro:db"; -import { db, Note } from "astro:db"; +import { db, Note, eq } from "astro:db"; import BaseLayout from "../../layouts/BaseLayout.astro"; import Link from "../../components/Link.astro"; import Webmentions from "../../components/Webmentions.svelte"; - import dayjs from "dayjs"; const { slug } = Astro.params; - -const notes = await db.select().from(Note).where(eq(slug, Note.published)) +const formattedSlug = Number(slug); +const notes = await db + .select() + .from(Note) + .limit(1) + // @ts-expect-error + .where(eq(formattedSlug, Note.published)); const note = notes[0]; - ---