new logic routes
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user