new logic routes

This commit is contained in:
Profile Profile
2026-01-22 00:00:07 +03:00
parent c5b00af520
commit ec2daae26b
4 changed files with 160 additions and 19 deletions

View File

@@ -1,16 +1,49 @@
---
import MainLayout from '@layouts/MainLayout.astro';
import NewsSingle from '@components/NewsSingle.astro';
import { detectPageType } from '@lib/detect-page-type';
import { getAnewsById } from '@lib/api/posts'; //логика
export const prerender = false;
const pathname = Astro.url.pathname; // "/news/society/chto-sluchilos-nochju-27-oktyabrya-2025-goda-1772178/"
const pageInfo = detectPageType(pathname);
//console.log(pageInfo);
// Или для полного URL
const fullUrl = Astro.url.href;
// Или для origin + pathname
const fullPath = Astro.url.origin + Astro.url.pathname;
if (pageInfo.type === 'single' && pageInfo.contentType === 'news') {
if (pageInfo.postId && typeof pageInfo.postId === 'number') {
const response = await getAnewsById(pageInfo.postId);
console.log(response);
//pageData = response?.post;
}
}
if (import.meta.env.DEV) {
const currentFile = import.meta.url
.replace('file://', '')
.replace(process.cwd(), '')
.replace(/^\//, '');
console.log('Файл:', currentFile);
}
---
<MainLayout>