Bu furkana ait bir gönderidir
Guest
import { ID } from 'appwrite'; import { marked } from 'marked'; import { databases } from '@lib/appwrite'; import Layout from '@layouts/Layout.astro'; import Container from '@components/Container.astro'; import { getPostID } from '@lib/postid';
const handlePostRequest = async (Astro) => { if (Astro.request.method === "POST") { const formData = await Astro.request.formData(); const username = await getPostID(); // Asenkron çağrı yaparak username alın
const data = {
title: String(formData.get('title')),
slug: String(formData.get('slug')),
content: await marked(String(formData.get('content'))),
username: username, // Alınan username'i kullan
};
const results = await databases.createDocument(
import.meta.env.PUBLIC_APPWRITE_DATABASE_ID,
import.meta.env.PUBLIC_APPWRITE_COLLECTION_ID,
ID.unique(),
data
);
return Astro.redirect(`/posts/${results.slug}`);
} };
await handlePostRequest(Astro);
hemide-öyledir