feat: admin paneli + blog + testimonials + SEO yöneticisi
Backend altyapısı: - 4 yeni Appwrite tablosu: blog_posts, testimonials, seo_pages, seo_settings - Appwrite Storage bucket: kovak-yazilim-media (görsel yüklemeleri) - Appwrite Auth ile session cookie tabanlı koruma Admin paneli (/admin): - Login akışı (email/password) + protected layout - Dashboard: sayım kartları + hızlı aksiyonlar - Blog CRUD: markdown content, kapak görseli, draft/published, SEO alanları - Services CRUD: lucide ikon seçici - Projects CRUD: teknoloji etiketleri, live URL - Testimonials CRUD: puanlama - SEO yöneticisi: global ayarlar + sayfa bazlı override - Mesaj inbox: status filtreleme + güncelleme - Medya kütüphanesi: Appwrite Storage upload/delete Public: - /blog ve /blog/[slug] sayfaları (markdown render) - Anasayfaya Testimonials bölümü - Tüm public sayfalarda generateMetadata + seo_pages override - Header'a Blog linki Route yapısı: - app/(site)/ — public site, Header/Footer ortak - app/admin/login — auth dışı - app/admin/(protected)/ — requireUser() korumalı 23 route üretiliyor, public static, admin dynamic.
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
import { PageHeader } from "@/components/admin/form";
|
||||
import { adminStorage, MEDIA_BUCKET_ID } from "@/lib/appwrite-server";
|
||||
import { Query } from "node-appwrite";
|
||||
import { Upload } from "lucide-react";
|
||||
import { DeleteButton } from "@/components/admin/delete-button";
|
||||
import { uploadMedia, deleteMediaFile } from "@/lib/admin-actions";
|
||||
|
||||
async function listFiles() {
|
||||
try {
|
||||
const res = await adminStorage.listFiles({
|
||||
bucketId: MEDIA_BUCKET_ID,
|
||||
queries: [Query.orderDesc("$createdAt"), Query.limit(100)],
|
||||
});
|
||||
return res.files;
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function fileViewUrl(id: string) {
|
||||
return `${process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT}/storage/buckets/${MEDIA_BUCKET_ID}/files/${id}/view?project=${process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID}`;
|
||||
}
|
||||
|
||||
export default async function MediaPage() {
|
||||
const files = await listFiles();
|
||||
|
||||
async function deleteAction(formData: FormData) {
|
||||
"use server";
|
||||
const id = String(formData.get("id"));
|
||||
await deleteMediaFile(id);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<PageHeader
|
||||
title="Medya kütüphanesi"
|
||||
description="Görselleri yükleyin ve URL'lerini kopyalayın."
|
||||
/>
|
||||
|
||||
<form
|
||||
action={uploadMedia}
|
||||
encType="multipart/form-data"
|
||||
className="mt-6 rounded-2xl border border-dashed border-[var(--border)] bg-white p-6"
|
||||
>
|
||||
<label className="flex flex-col items-center gap-3 text-center">
|
||||
<Upload className="size-8 text-[var(--sky-600)]" />
|
||||
<span className="text-sm font-medium text-[var(--navy)]">
|
||||
Görsel yüklemek için dosya seçin (max 10 MB)
|
||||
</span>
|
||||
<input
|
||||
name="file"
|
||||
type="file"
|
||||
accept="image/*"
|
||||
required
|
||||
className="block max-w-md text-sm"
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
className="rounded-full bg-[var(--navy)] px-5 py-2 text-sm font-medium text-white transition hover:bg-[var(--navy-700)]"
|
||||
>
|
||||
Yükle
|
||||
</button>
|
||||
</label>
|
||||
</form>
|
||||
|
||||
<div className="mt-8 grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||
{files.length === 0 && (
|
||||
<div className="col-span-full rounded-2xl border border-dashed border-[var(--border)] bg-white p-12 text-center text-sm text-[var(--muted)]">
|
||||
Henüz görsel yüklenmemiş.
|
||||
</div>
|
||||
)}
|
||||
{files.map((f) => {
|
||||
const url = fileViewUrl(f.$id);
|
||||
return (
|
||||
<div
|
||||
key={f.$id}
|
||||
className="overflow-hidden rounded-xl border border-[var(--border)] bg-white"
|
||||
>
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img
|
||||
src={url}
|
||||
alt={f.name}
|
||||
className="aspect-square w-full object-cover"
|
||||
loading="lazy"
|
||||
/>
|
||||
<div className="p-3">
|
||||
<p className="truncate text-xs font-medium text-[var(--navy)]">
|
||||
{f.name}
|
||||
</p>
|
||||
<p className="text-[10px] text-[var(--muted)]">
|
||||
{(f.sizeOriginal / 1024).toFixed(0)} KB
|
||||
</p>
|
||||
<div className="mt-2 flex items-center justify-between gap-2">
|
||||
<a
|
||||
href={url}
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
className="text-xs text-[var(--sky-600)] hover:text-[var(--navy)]"
|
||||
>
|
||||
Aç ↗
|
||||
</a>
|
||||
<form action={deleteAction}>
|
||||
<input type="hidden" name="id" value={f.$id} />
|
||||
<DeleteButton label="Sil" />
|
||||
</form>
|
||||
</div>
|
||||
<input
|
||||
readOnly
|
||||
value={url}
|
||||
className="mt-2 w-full truncate rounded-md border border-[var(--border)] bg-[var(--navy-50)] px-2 py-1 text-[10px] text-[var(--muted)]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user