import "dotenv/config"; import { pathToFileURL } from "node:url"; import { count } from "drizzle-orm"; import { drizzle } from "drizzle-orm/node-postgres"; import { Pool } from "pg"; import { navItems, pages, postTags, posts, settings, tags, users, } from "../src/db/schema"; import { hashPassword } from "../src/lib/auth/password"; // Bodies below are authored in Markdown for maintainability, but the // database stores editor HTML — convert at insert time. import { renderMarkdown } from "../src/lib/markdown"; import { slugify } from "../src/lib/slug"; const POST_BODIES = { hello: `Welcome to **Yap Blog**, a small blog that runs on Next.js, PostgreSQL, and Drizzle ORM. This post exists so the front page is not empty on first boot. Log in at [/admin](/admin) to write your own, or delete everything here and start fresh. ## What you can do - Write posts in Markdown with a live preview - Organize them with tags - Publish static pages and pin them to the navigation - Point the home page at the post list, a tag, or a page > The best time to start a blog was ten years ago. The second-best time is tonight, after dark, in base03. Happy writing!`, solarized: `Every terminal eventually goes through a phase. Mine never left it. [Solarized](https://ethanschoonover.com/solarized/) is a sixteen-color palette designed by Ethan Schoonover with *fixed contrast relationships* — the light and dark variants share the same four accent-friendly content tones, so switching themes never changes how loud your text feels. ## The dark half | Name | Hex | Role | | ------ | --------- | ----------------------- | | base03 | \`#002b36\` | background | | base02 | \`#073642\` | highlighted background | | base01 | \`#586e75\` | secondary text | | base0 | \`#839496\` | body text | | base1 | \`#93a1a1\` | emphasized text | The trick is that nothing is ever pure black or pure white. The background is a deep blue-green lagoon, and the text hovers above it like fog. ## Why it survives Fashion cycles through editor themes the way it cycles through denim. Solarized persists because it was *engineered*, not just picked: every pair of tones was checked for perceptual contrast on calibrated displays in both CIELAB and by tired human eyes at 2 a.m. This blog wears it out of gratitude.`, markdown: `Everything on this site is written in Markdown and rendered server-side through a sanitizing pipeline. This post is the kitchen sink that proves it. ## Text Plain paragraphs, **bold**, *italics*, ~~strikethrough~~, and \`inline code\` all work. So do [links](https://www.markdownguide.org/) and footnote-ish parentheticals (like this one). ## Lists 1. Ordered lists 2. With multiple items - And nested bullets - Like these ## Code \`\`\`ts export function slugify(input: string): string { return input .normalize("NFKD") .toLowerCase() .replace(/[^a-z0-9]+/g, "-") .replace(/^-+|-+$/g, ""); } \`\`\` ## Quotes and rules > A blockquote, styled with a Solarized comment-tone border. --- ## Tables | Feature | Supported | | --------- | --------- | | GFM tables | yes | | Task lists | mostly | ## What does *not* work Raw \`