Add Django backend, Next.js frontend, and deploy templates

This commit is contained in:
ogrechko committed 2026-08-27 15:38:31 +00:00
1 parent fc0c991335
commit e9cd22d36f
93 files changed
+7840 -1

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
import { fallbackHome, fallbackPages, fallbackServices } from "@/lib/fallback-data";
import { HomePayload, Page, Service } from "@/lib/types";
const API_URL = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000/api";
async function request<T>(path: string, fallback: T): Promise<T> {
try {
const response = await fetch(`${API_URL}${path}`, {
next: { revalidate: 60 },
});
if (!response.ok) {
return fallback;
}
return (await response.json()) as T;
} catch {
return fallback;
}
}
export function getHomeData(): Promise<HomePayload> {
return request("/home/", fallbackHome);
}
export function getPages(): Promise<Page[]> {
return request("/pages/", fallbackPages);
}
export function getPage(slug: string): Promise<Page | null> {
return request(`/pages/${slug}/`, fallbackPages.find((item) => item.slug === slug) || null);
}
export function getServices(): Promise<Service[]> {
return request("/services/", fallbackServices);
}
export function getService(slug: string): Promise<Service | null> {
return request(`/services/${slug}/`, fallbackServices.find((item) => item.slug === slug) || null);
}