fix admin

This commit is contained in:
haetae 2025-09-22 16:50:13 -04:00
parent e384937596
commit e143587404
3 changed files with 9 additions and 7 deletions

View File

@ -1,9 +1,9 @@
import { db, Guestbook } from 'astro:db';
import { db } from "db";
import { guestbookTable } from "./schema";
// https://astro.build/db/seed
export default async function seed() {
await db.insert(Guestbook).values([
{ id: 1, username: "test user", message: "this is a message!", published: new Date("2025-05-01") },
await db.insert(guestbookTable).values([
{ id: 1, username: "test user", message: "this is a message!" },
{ id: 2, username: "heylo", website: "https://world.org", message: "hiii!!" },
]);
}

View File

@ -3,7 +3,9 @@ export const prerender = false;
import { Font } from "astro:assets";
import { actions } from "astro:actions";
import { db, desc, Guestbook } from "astro:db";
import { desc } from "drizzle-orm";
import { db } from "db";
import { guestbookTable } from "db/schema";
import Layout from "@/layouts/Layout.astro";
import formatDate from "@/utils/formatDate";
@ -14,7 +16,7 @@ if (!import.meta.env.DEV) {
return Astro.redirect("/guestbook");
}
const entries = await db.select().from(Guestbook).orderBy(desc(Guestbook.published));
const entries = await db.select().from(guestbookTable).orderBy(desc(guestbookTable.published));
---
<Layout title="guestbook admin">
<Fragment slot="head">

View File

@ -3,7 +3,7 @@ import utc from "dayjs/plugin/utc";
dayjs.extend(utc);
export default function (date: string, iso = false, format?: string) {
export default function (date: Date | string, iso = false, format?: string) {
if (iso) {
return dayjs(date).utc(true).toISOString();
} else {