57 lines
1.3 KiB
Plaintext
57 lines
1.3 KiB
Plaintext
---
|
|
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>
|
|
<div>
|
|
<p><strong>pathname:</strong> {pathname}</p>
|
|
<p><strong>Page Type:</strong> {pageInfo.type}</p>
|
|
<p><strong>Content Type:</strong> {pageInfo.contentType}</p>
|
|
<p><strong>Full URL:</strong> {fullUrl}</p>
|
|
</div>
|
|
</MainLayout>
|