feat: anasayfa içeriği, iletişim ve sosyal medya yönetilebilir
Yeni site_settings tablosu (singleton, rowId='homepage'): - Hero: badge, title, subtitle, 2 CTA (label+href), stats (JSON array) - Section başlıkları: services/projects/testimonials eyebrow + title + description - Alt CTA: title, description, button label+href - Contact: phone (görünen + tel: ham), email, address, hafta içi/sonu saatleri - Social: linkedin/instagram/twitter/facebook URL'leri - Footer tagline Mevcut hardcoded değerler seed edildi. Admin: - /admin/site sayfası eklendi (sidebar'a 'Site Ayarları' linki) - Bölümlü tek form: Hero / Hizmetler / Projeler / Referanslar / Alt CTA / İletişim / Sosyal / Footer - Stats için 'değer | etiket' satır formatı Public bağlantılar: - Hero component artık settings prop alıyor (fallback değerlerle) - Anasayfa: tüm section başlıkları ve alt CTA settings'ten geliyor - Header: telefon settings'ten - Footer: tagline, adres, telefon, email, sosyal linkler settings'ten (sosyal link sadece dolu olanlar gösteriliyor) - Footer'da hizmetler artık /hizmetler/[slug] detay sayfalarına bağlı - İletişim sayfası: adres, telefon, email, saatler settings'ten 30 route üretiliyor.
This commit is contained in:
@@ -281,6 +281,85 @@ export async function deleteTestimonial(formData: FormData) {
|
||||
revalidatePath("/admin/referanslar");
|
||||
}
|
||||
|
||||
// ─── Site Settings (homepage content) ────────────────────────────
|
||||
|
||||
export async function saveSiteSettings(formData: FormData) {
|
||||
const secret = await requireSessionSecret();
|
||||
|
||||
// Hero stats: 3 satır halinde "value|label" formatında — JSON array'e çevir
|
||||
const statsRaw = String(formData.get("hero_stats") ?? "");
|
||||
const stats = statsRaw
|
||||
.split("\n")
|
||||
.map((line) => {
|
||||
const [value, label] = line.split("|").map((s) => s.trim());
|
||||
if (!value || !label) return null;
|
||||
return JSON.stringify({ value, label });
|
||||
})
|
||||
.filter((x): x is string => x !== null);
|
||||
|
||||
const data = {
|
||||
hero_badge: str(formData.get("hero_badge")),
|
||||
hero_title: str(formData.get("hero_title")),
|
||||
hero_subtitle: str(formData.get("hero_subtitle")),
|
||||
hero_cta_primary_label: str(formData.get("hero_cta_primary_label")),
|
||||
hero_cta_primary_href: str(formData.get("hero_cta_primary_href")),
|
||||
hero_cta_secondary_label: str(formData.get("hero_cta_secondary_label")),
|
||||
hero_cta_secondary_href: str(formData.get("hero_cta_secondary_href")),
|
||||
hero_stats: stats.length > 0 ? stats : null,
|
||||
|
||||
services_eyebrow: str(formData.get("services_eyebrow")),
|
||||
services_title: str(formData.get("services_title")),
|
||||
services_description: str(formData.get("services_description")),
|
||||
|
||||
projects_eyebrow: str(formData.get("projects_eyebrow")),
|
||||
projects_title: str(formData.get("projects_title")),
|
||||
projects_description: str(formData.get("projects_description")),
|
||||
|
||||
testimonials_eyebrow: str(formData.get("testimonials_eyebrow")),
|
||||
testimonials_title: str(formData.get("testimonials_title")),
|
||||
testimonials_description: str(formData.get("testimonials_description")),
|
||||
|
||||
cta_title: str(formData.get("cta_title")),
|
||||
cta_description: str(formData.get("cta_description")),
|
||||
cta_button_label: str(formData.get("cta_button_label")),
|
||||
cta_button_href: str(formData.get("cta_button_href")),
|
||||
|
||||
contact_phone: str(formData.get("contact_phone")),
|
||||
contact_phone_raw: str(formData.get("contact_phone_raw")),
|
||||
contact_email: str(formData.get("contact_email")),
|
||||
contact_address: str(formData.get("contact_address")),
|
||||
contact_hours_weekday: str(formData.get("contact_hours_weekday")),
|
||||
contact_hours_weekend: str(formData.get("contact_hours_weekend")),
|
||||
|
||||
social_linkedin: str(formData.get("social_linkedin")),
|
||||
social_instagram: str(formData.get("social_instagram")),
|
||||
social_twitter: str(formData.get("social_twitter")),
|
||||
social_facebook: str(formData.get("social_facebook")),
|
||||
|
||||
footer_tagline: str(formData.get("footer_tagline")),
|
||||
};
|
||||
|
||||
try {
|
||||
await tablesDB.updateRow(
|
||||
DATABASE_ID,
|
||||
TABLES.siteSettings,
|
||||
"homepage",
|
||||
data,
|
||||
secret,
|
||||
);
|
||||
} catch {
|
||||
await tablesDB.createRow(
|
||||
DATABASE_ID,
|
||||
TABLES.siteSettings,
|
||||
"homepage",
|
||||
data,
|
||||
secret,
|
||||
);
|
||||
}
|
||||
revalidatePath("/", "layout");
|
||||
revalidatePath("/admin/site");
|
||||
}
|
||||
|
||||
// ─── SEO Settings ────────────────────────────────────────────────
|
||||
|
||||
export async function saveSeoSettings(formData: FormData) {
|
||||
|
||||
@@ -21,6 +21,7 @@ export const TABLES = {
|
||||
testimonials: "testimonials",
|
||||
seoPages: "seo_pages",
|
||||
seoSettings: "seo_settings",
|
||||
siteSettings: "site_settings",
|
||||
} as const;
|
||||
|
||||
export class AppwriteError extends Error {
|
||||
|
||||
+13
@@ -8,6 +8,7 @@ import type {
|
||||
ServiceRow,
|
||||
SeoPageRow,
|
||||
SeoSettingsRow,
|
||||
SiteSettingsRow,
|
||||
TestimonialRow,
|
||||
} from "@/lib/types";
|
||||
|
||||
@@ -118,6 +119,18 @@ export async function listSeoPages() {
|
||||
]);
|
||||
}
|
||||
|
||||
export async function getSiteSettings(): Promise<SiteSettingsRow | null> {
|
||||
try {
|
||||
return await tablesDB.getRow<SiteSettingsRow>(
|
||||
DATABASE_ID,
|
||||
TABLES.siteSettings,
|
||||
"homepage",
|
||||
);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getSeoSettings(): Promise<SeoSettingsRow | null> {
|
||||
try {
|
||||
return await tablesDB.getRow<SeoSettingsRow>(
|
||||
|
||||
@@ -86,6 +86,53 @@ export interface SeoSettingsRow extends AwRow {
|
||||
gtm_id?: string | null;
|
||||
}
|
||||
|
||||
export interface StatItem {
|
||||
value: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface SiteSettingsRow extends AwRow {
|
||||
hero_badge?: string | null;
|
||||
hero_title?: string | null;
|
||||
hero_subtitle?: string | null;
|
||||
hero_cta_primary_label?: string | null;
|
||||
hero_cta_primary_href?: string | null;
|
||||
hero_cta_secondary_label?: string | null;
|
||||
hero_cta_secondary_href?: string | null;
|
||||
hero_stats?: string[] | null; // each item JSON: {"value":"...","label":"..."}
|
||||
|
||||
services_eyebrow?: string | null;
|
||||
services_title?: string | null;
|
||||
services_description?: string | null;
|
||||
|
||||
projects_eyebrow?: string | null;
|
||||
projects_title?: string | null;
|
||||
projects_description?: string | null;
|
||||
|
||||
testimonials_eyebrow?: string | null;
|
||||
testimonials_title?: string | null;
|
||||
testimonials_description?: string | null;
|
||||
|
||||
cta_title?: string | null;
|
||||
cta_description?: string | null;
|
||||
cta_button_label?: string | null;
|
||||
cta_button_href?: string | null;
|
||||
|
||||
contact_phone?: string | null;
|
||||
contact_phone_raw?: string | null;
|
||||
contact_email?: string | null;
|
||||
contact_address?: string | null;
|
||||
contact_hours_weekday?: string | null;
|
||||
contact_hours_weekend?: string | null;
|
||||
|
||||
social_linkedin?: string | null;
|
||||
social_instagram?: string | null;
|
||||
social_twitter?: string | null;
|
||||
social_facebook?: string | null;
|
||||
|
||||
footer_tagline?: string | null;
|
||||
}
|
||||
|
||||
export interface ContactMessageRow extends AwRow {
|
||||
name: string;
|
||||
email: string;
|
||||
|
||||
Reference in New Issue
Block a user