Skip to content

Commit

Permalink
expect an error
Browse files Browse the repository at this point in the history
  • Loading branch information
spcbfr committed Mar 26, 2024
1 parent 60314da commit 0596cd4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion db/seed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Note, db } from "astro:db";
import dayjs from "dayjs";

// https://astro.build/db/seed
export default async function seed() {
Expand All @@ -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,
},
]);
}
18 changes: 9 additions & 9 deletions src/pages/notes/[slug].astro
Original file line number Diff line number Diff line change
@@ -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];
---

<BaseLayout
Expand All @@ -33,9 +35,7 @@ const note = notes[0];
</div>
<div>
<time class="text-sm" datetime={dayjs(note.published).toISOString()}>
{
dayjs(note.published).format("ddd, D MMM, YYYY, HH:mm")
}
{dayjs(note.published).format("ddd, D MMM, YYYY, HH:mm")}
</time>
</div>
</article>
Expand Down

0 comments on commit 0596cd4

Please sign in to comment.