new logic routes
This commit is contained in:
@@ -186,6 +186,98 @@ export async function getProfileArticleById(databaseId) {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Получить Anews пост по databaseId
|
||||
*/
|
||||
export async function getAnewsById(databaseId: number): Promise<SingleAnewsPost | null> {
|
||||
const cacheKey = `anews:${databaseId}`;
|
||||
|
||||
return await cache.wrap(
|
||||
cacheKey,
|
||||
async () => {
|
||||
const query = `
|
||||
query GetAnewsById($id: ID!) {
|
||||
aNews(id: $id, idType: DATABASE_ID) {
|
||||
id
|
||||
databaseId
|
||||
title
|
||||
content
|
||||
excerpt
|
||||
uri
|
||||
slug
|
||||
date
|
||||
modified
|
||||
status
|
||||
featuredImage {
|
||||
node {
|
||||
id
|
||||
sourceUrl
|
||||
altText
|
||||
caption
|
||||
mediaDetails {
|
||||
width
|
||||
height
|
||||
}
|
||||
}
|
||||
}
|
||||
author {
|
||||
node {
|
||||
id
|
||||
name
|
||||
firstName
|
||||
lastName
|
||||
avatar {
|
||||
url
|
||||
}
|
||||
description
|
||||
uri
|
||||
}
|
||||
}
|
||||
categories {
|
||||
nodes {
|
||||
id
|
||||
name
|
||||
slug
|
||||
uri
|
||||
description
|
||||
}
|
||||
}
|
||||
tags {
|
||||
nodes {
|
||||
id
|
||||
name
|
||||
slug
|
||||
uri
|
||||
}
|
||||
}
|
||||
seo {
|
||||
title
|
||||
metaDesc
|
||||
canonical
|
||||
opengraphTitle
|
||||
opengraphDescription
|
||||
opengraphImage {
|
||||
sourceUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
try {
|
||||
const data = await fetchGraphQL(query, { id: databaseId });
|
||||
return data?.aNews || null;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching Anews post with ID ${databaseId}:`, error);
|
||||
return null;
|
||||
}
|
||||
},
|
||||
{ ttl: CACHE_TTL.POST_DETAIL } // Можно использовать отдельный TTL для деталей постов
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user