add news post

This commit is contained in:
Profile Profile
2026-02-18 23:33:35 +03:00
parent 9e32f4f064
commit b58b35bf47
6 changed files with 135 additions and 111 deletions

View File

@@ -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;