add news post
This commit is contained in:
@@ -209,15 +209,15 @@ export async function getProfileArticleById(databaseId) {
|
||||
/**
|
||||
* Получить Anews пост по databaseId
|
||||
*/
|
||||
export async function getAnewsById(databaseId: number): Promise<SingleAnewsPost | null> {
|
||||
export async function getAnewById(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) {
|
||||
query GetAnewById($id: ID!) {
|
||||
aNew(id: $id, idType: DATABASE_ID) {
|
||||
id
|
||||
databaseId
|
||||
title
|
||||
@@ -270,23 +270,13 @@ export async function getAnewsById(databaseId: number): Promise<SingleAnewsPost
|
||||
uri
|
||||
}
|
||||
}
|
||||
seo {
|
||||
title
|
||||
metaDesc
|
||||
canonical
|
||||
opengraphTitle
|
||||
opengraphDescription
|
||||
opengraphImage {
|
||||
sourceUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
try {
|
||||
const data = await fetchGraphQL(query, { id: databaseId });
|
||||
return data?.aNews || null;
|
||||
return data?.aNew || null;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching Anews post with ID ${databaseId}:`, error);
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user