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:
Ege Can Komur
2026-05-20 02:13:09 +03:00
parent 0f20309e4d
commit f833d429fc
52 changed files with 2999 additions and 81 deletions
+91 -15
View File
@@ -1,34 +1,110 @@
import "server-only";
import { Query } from "node-appwrite";
import { serverTablesDB, DATABASE_ID, TABLES } from "@/lib/appwrite-server";
import type { ProjectRow, ServiceRow } from "@/lib/types";
import { adminDB, DATABASE_ID, TABLES } from "@/lib/appwrite-server";
import type {
BlogPostRow,
ContactMessageRow,
ProjectRow,
ServiceRow,
SeoPageRow,
SeoSettingsRow,
TestimonialRow,
} from "@/lib/types";
export async function listServices(opts?: { featured?: boolean }) {
const queries = [Query.orderAsc("order"), Query.limit(50)];
if (opts?.featured) queries.unshift(Query.equal("featured", true));
async function safeList<T>(
tableId: string,
queries: string[],
): Promise<T[]> {
try {
const res = await serverTablesDB.listRows<ServiceRow>({
const res = await adminDB.listRows<T extends import("appwrite").Models.Row ? T : never>({
databaseId: DATABASE_ID,
tableId: TABLES.services,
tableId,
queries,
});
return res.rows;
return res.rows as T[];
} catch {
return [];
}
}
export async function listServices(opts?: { featured?: boolean }) {
const q = [Query.orderAsc("order"), Query.limit(50)];
if (opts?.featured) q.unshift(Query.equal("featured", true));
return safeList<ServiceRow>(TABLES.services, q);
}
export async function listProjects(opts?: { featured?: boolean; limit?: number }) {
const queries = [Query.orderDesc("year"), Query.limit(opts?.limit ?? 50)];
if (opts?.featured) queries.unshift(Query.equal("featured", true));
const q = [Query.orderDesc("year"), Query.limit(opts?.limit ?? 50)];
if (opts?.featured) q.unshift(Query.equal("featured", true));
return safeList<ProjectRow>(TABLES.projects, q);
}
export async function listPublishedPosts(opts?: { limit?: number }) {
return safeList<BlogPostRow>(TABLES.blogPosts, [
Query.equal("status", "published"),
Query.orderDesc("published_at"),
Query.limit(opts?.limit ?? 50),
]);
}
export async function listAllPosts() {
return safeList<BlogPostRow>(TABLES.blogPosts, [
Query.orderDesc("$createdAt"),
Query.limit(200),
]);
}
export async function getPostBySlug(slug: string): Promise<BlogPostRow | null> {
const res = await safeList<BlogPostRow>(TABLES.blogPosts, [
Query.equal("slug", slug),
Query.limit(1),
]);
return res[0] ?? null;
}
export async function listTestimonials(opts?: { featured?: boolean }) {
const q = [Query.orderAsc("order"), Query.limit(50)];
if (opts?.featured) q.unshift(Query.equal("featured", true));
return safeList<TestimonialRow>(TABLES.testimonials, q);
}
export async function listMessages(status?: ContactMessageRow["status"]) {
const q = [Query.orderDesc("$createdAt"), Query.limit(200)];
if (status) q.unshift(Query.equal("status", status));
return safeList<ContactMessageRow>(TABLES.contactMessages, q);
}
export async function getSeoPage(path: string): Promise<SeoPageRow | null> {
const res = await safeList<SeoPageRow>(TABLES.seoPages, [
Query.equal("path", path),
Query.limit(1),
]);
return res[0] ?? null;
}
export async function listSeoPages() {
return safeList<SeoPageRow>(TABLES.seoPages, [
Query.orderAsc("path"),
Query.limit(200),
]);
}
export async function getSeoSettings(): Promise<SeoSettingsRow | null> {
try {
const res = await serverTablesDB.listRows<ProjectRow>({
return await adminDB.getRow<SeoSettingsRow>({
databaseId: DATABASE_ID,
tableId: TABLES.projects,
queries,
tableId: TABLES.seoSettings,
rowId: "global",
});
return res.rows;
} catch {
return [];
return null;
}
}
export async function getRow<T>(tableId: string, rowId: string): Promise<T | null> {
try {
return (await adminDB.getRow({ databaseId: DATABASE_ID, tableId, rowId })) as T;
} catch {
return null;
}
}