upd
This commit is contained in:
@@ -13,8 +13,8 @@ export interface PageProps {
|
||||
|
||||
export default async function PostPage({ params }: PageProps) {
|
||||
const { slug } = await params;
|
||||
const baseUrl =
|
||||
process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3000';
|
||||
|
||||
const baseUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3000';
|
||||
|
||||
const res = await fetch(`${baseUrl}/api/posts/${slug}`, {
|
||||
next: { revalidate: 60 },
|
||||
|
||||
@@ -1,14 +1,34 @@
|
||||
// app/page.tsx
|
||||
import Flex from '@/components/Blocks/Flex/Flex';
|
||||
import Grid from '@/components/Blocks/Grid/Grid';
|
||||
import IFrame from '@/components/Blocks/IFrame/IFrame';
|
||||
import Section from '@/components/Blocks/Section/Section';
|
||||
import PostCard from '@/components/Post/PostCard';
|
||||
import EmblaCarousel from '@/components/UI/EmblaCarousel/EmblaCarousel';
|
||||
import Stat from '@/components/UI/Stat/Stat';
|
||||
import Areas from '@/components/WP/Areas/Areas';
|
||||
import { SmartSlider } from '@/components/WPRenderer/SmartSlider';
|
||||
import { renderPostContent } from '@/components/WPRenderer/WPRenderer';
|
||||
import { connection } from '@/lib/duckdb';
|
||||
import { transformLinks } from '@/lib/utils';
|
||||
import { CarouselSlide, PostData } from '@/types/entities';
|
||||
|
||||
export const revalidate = 10;
|
||||
|
||||
export default async function HomePage() {
|
||||
const duckRes = await connection.run(`
|
||||
SELECT p.*
|
||||
FROM wp_posts p
|
||||
WHERE p.ID = (
|
||||
SELECT option_value
|
||||
FROM wp_options
|
||||
WHERE option_name = 'page_on_front'
|
||||
LIMIT 1
|
||||
)
|
||||
LIMIT 1;`);
|
||||
|
||||
const duckData = await duckRes.getRowObjectsJson()
|
||||
|
||||
const baseUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3000';
|
||||
|
||||
const res = await fetch(`${baseUrl}/api/home`, { next: { revalidate: 10 }, });
|
||||
@@ -18,7 +38,8 @@ export default async function HomePage() {
|
||||
throw new Error('Failed to fetch home posts');
|
||||
}
|
||||
|
||||
const posts: PostData[] = await res.json();
|
||||
//const posts: PostData[] = await res.json();
|
||||
const posts = duckData
|
||||
|
||||
const stats: { title: string, value: string }[] = [
|
||||
{
|
||||
@@ -206,36 +227,67 @@ export default async function HomePage() {
|
||||
]
|
||||
|
||||
return (
|
||||
<div className="w-full flex flex-col items-center sm:gap-8 mb-8">
|
||||
<div className="w-full flex flex-col items-center sm:gap-8">
|
||||
{/* {posts.map(post => (
|
||||
<div key={post.ID} className="max-w-5xl">
|
||||
{renderPostContent(post.post_content)}
|
||||
</div>
|
||||
))} */}
|
||||
|
||||
<EmblaCarousel title_align='left' title_position='top' show_dots={true} show_title={true} slides={slides} />
|
||||
<EmblaCarousel autoplay title_align='left' title_position='top' show_dots={true} show_title={true} slides={slides} />
|
||||
|
||||
<Section title='Новости'>
|
||||
<div className='grid grid-cols-2 space-y-4 space-x-4'>
|
||||
<Grid gap={4} cols_mobile={1} cols_tablet={1} cols_desktop={2} rows_mobile={1} rows_tablet={1} rows_desktop={1}>
|
||||
<EmblaCarousel rounded title_align='left' shape='square' show_title title_position='bottom' autoplay={true} show_dots={true} slides_per_view={1} slides={slides} dots_position='bottom_inside' />
|
||||
</div>
|
||||
|
||||
<Flex justify='between' direction='col' gap={4}>
|
||||
<PostCard
|
||||
thumbnail_src='https://new.jkhsakha.ru/wp-content/uploads/2026/02/1-1-300x179.jpeg'
|
||||
post_href='/#'
|
||||
description='Post card test'
|
||||
title='Работники ЖКХ – обладатели Гран-при военно-патриотического конкурса'
|
||||
show_thumbnail={true}
|
||||
show_categories
|
||||
categories={[
|
||||
{
|
||||
id: 0,
|
||||
slug: 'news',
|
||||
name: 'Новости'
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
slug: 'news',
|
||||
name: 'Новости'
|
||||
}
|
||||
]}
|
||||
date='26.02.2026'
|
||||
show_date
|
||||
/>
|
||||
<PostCard
|
||||
post_href='/#'
|
||||
title='Осторожно! Мошенники рассылают СМС о возврате за отопление'
|
||||
description='asd'
|
||||
/>
|
||||
<PostCard
|
||||
post_href='/#'
|
||||
title='Профсоюз ГУП «ЖКХ РС(Я)» поздравил ветеранов с наступающим Новым годом'
|
||||
|
||||
/>
|
||||
</Flex>
|
||||
</Grid>
|
||||
</Section>
|
||||
|
||||
<Section title='О предприятии'>
|
||||
<div className={`grid grid-cols-1 lg:grid-cols-2 justify-center items-center`}>
|
||||
<div>
|
||||
<Areas />
|
||||
</div>
|
||||
<Grid cols_mobile={1} cols_tablet={1} cols_desktop={2} rows_mobile={1} rows_tablet={1} rows_desktop={1}>
|
||||
<Areas />
|
||||
|
||||
<div className="grid grid-cols-2 space-y-4 space-x-4">
|
||||
|
||||
<Grid cols_desktop={2} cols_mobile={2} cols_tablet={2} gap={4}>
|
||||
{stats.map((stat, index) => (
|
||||
<div key={index} className="grid grid-rows-[min-content_1fr] space-y-2">
|
||||
<div className="stat-value text-3xl sm:text-5xl text-[#0063A7]">{stat.value}</div>
|
||||
<div className="stat-title text-wrap text-lg sm:text-2xl text-neutral">{stat.title}</div>
|
||||
</div>
|
||||
<Stat key={index} value={stat.value} title={stat.title} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Section>
|
||||
|
||||
<Section title='Филиалы'>
|
||||
@@ -245,6 +297,12 @@ export default async function HomePage() {
|
||||
<Section title="Контакты">
|
||||
|
||||
</Section>
|
||||
|
||||
<IFrame iframe={`<iframe loading="lazy"
|
||||
src="https://maps.google.com/maps?q=%D0%B3.%20%D0%AF%D0%BA%D1%83%D1%82%D1%81%D0%BA%2C%20%D1%83%D0%BB.%20%D0%9A%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%2C%20%D0%B4.18%2C%20%D0%B1%D0%BB%D0%BE%D0%BA%20%22%D0%90%22&t=m&z=16&output=embed&iwloc=near"
|
||||
title="г. Якутск, ул. Кирова, д.18, блок "А""
|
||||
aria-label="г. Якутск, ул. Кирова, д.18, блок "А""
|
||||
></iframe>`} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import { PageProps } from "@/app/(client)/[slug]/page";
|
||||
import PostPage from "@/app/(client)/[slug]/page";
|
||||
import ClientLayout from "@/app/(client)/layout";
|
||||
import Post from "@/components/Post/Post";
|
||||
import Tiptap from "@/components/Tiptap/Tiptap";
|
||||
|
||||
export default async function EditorPage({ params }: PageProps) {
|
||||
|
||||
@@ -5,7 +5,7 @@ export const montserratFont = Montserrat({
|
||||
subsets: ['latin', 'cyrillic'],
|
||||
})
|
||||
|
||||
const mainFont = Roboto({
|
||||
export const mainFont = Roboto({
|
||||
subsets: ['latin', 'cyrillic'],
|
||||
})
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import type { Data } from "@puckeditor/core";
|
||||
import { Render } from "@puckeditor/core";
|
||||
import puckConfig from "../../../puck.config";
|
||||
|
||||
export function Client({ data }: { data: Data }) {
|
||||
return <Render config={puckConfig} data={data} />
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/**
|
||||
* This file implements a catch-all route that renders the user-facing pages
|
||||
* generated by Puck. For any route visited (with exception of other hardcoded
|
||||
* pages in /app), it will check your database (via `getPage`) for a Puck page
|
||||
* and render it using <Render>.
|
||||
*
|
||||
* All routes produced by this page are statically rendered using incremental
|
||||
* static site generation. After the first visit, the page will be cached as
|
||||
* a static file. Subsequent visits will receive the cache. Publishing a page
|
||||
* will invalidate the cache as the page is written in /api/puck/route.ts
|
||||
*/
|
||||
|
||||
import { Client } from "./client";
|
||||
import { notFound } from "next/navigation";
|
||||
import { Metadata } from "next";
|
||||
import { getPage } from "@/lib/get-page";
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ puckPath: string[] }>;
|
||||
}): Promise<Metadata> {
|
||||
const { puckPath = [] } = await params;
|
||||
const path = `/${puckPath.join("/")}`;
|
||||
|
||||
const data = getPage(path)
|
||||
return {
|
||||
title: data?.root.props?.title,
|
||||
};
|
||||
}
|
||||
|
||||
export default async function Page({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ puckPath: string[] }>;
|
||||
}) {
|
||||
const { puckPath = [] } = await params;
|
||||
const path = `/${puckPath.join("/")}`;
|
||||
const data = await getPage(path);
|
||||
|
||||
if (!data) {
|
||||
return notFound();
|
||||
}
|
||||
|
||||
return <Client data={data} />;
|
||||
}
|
||||
|
||||
// Force Next.js to produce static pages: https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#dynamic
|
||||
// Delete this if you need dynamic rendering, such as access to headers or cookies
|
||||
export const dynamic = "force-static";
|
||||
@@ -1,13 +1,15 @@
|
||||
// app/page.tsx
|
||||
|
||||
import Areas from "@/components/WP/Areas/Areas";
|
||||
import GetLK from "@/components/WP/GetLK/GetLK";
|
||||
|
||||
export const revalidate = 10;
|
||||
|
||||
export default async function TestPage() {
|
||||
return (
|
||||
<div className="w-full flex flex-col items-center">
|
||||
<Areas />
|
||||
{/* <Areas /> */}
|
||||
<GetLK />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user