add new logic routes
This commit is contained in:
@@ -1,30 +1,23 @@
|
||||
---
|
||||
import MainLayout from '@layouts/MainLayout.astro';
|
||||
import { getNodeByURI, getCategoryPosts } from '@lib/api/all';
|
||||
import { detectPageType } from '@lib/detect-page-type';
|
||||
|
||||
export const prerender = false;
|
||||
|
||||
const { slug } = Astro.params;
|
||||
const uri = slug ? `/${slug}` : '/';
|
||||
const pathname = Astro.url.pathname; // "/news/society/chto-sluchilos-nochju-27-oktyabrya-2025-goda-1772178/"
|
||||
const pageInfo = detectPageType(pathname);
|
||||
|
||||
let response;
|
||||
let node = null;
|
||||
|
||||
try {
|
||||
response = await getNodeByURI(uri);
|
||||
node = response?.nodeByUri;
|
||||
} catch (error) {
|
||||
console.error('Error fetching node:', error);
|
||||
}
|
||||
|
||||
// ISR кэширование
|
||||
//Astro.response.headers.set(
|
||||
// 'Cache-Control',
|
||||
// 'public, s-maxage=3600, stale-while-revalidate=86400'
|
||||
//);
|
||||
// Или для полного URL
|
||||
const fullUrl = Astro.url.href;
|
||||
// Или для origin + pathname
|
||||
const fullPath = Astro.url.origin + Astro.url.pathname;
|
||||
---
|
||||
|
||||
News
|
||||
|
||||
<p>{uri}</p>
|
||||
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user