add emmed

This commit is contained in:
Profile Profile
2026-03-14 18:01:30 +03:00
parent 684a7bffbf
commit f66c3baf8d
10 changed files with 338 additions and 235 deletions

View File

@@ -345,7 +345,7 @@ export async function getPostsByTag(slug, first = 14, after = null) {
}
`;
console.log('Fetching with:', { first, after, slug }); // Добавим лог параметров
//console.log('Fetching with:', { first, after, slug }); // Добавим лог параметров
const data = await fetchGraphQL(query, { first, after, slug });
@@ -616,6 +616,65 @@ export async function getTagBySlug(slug) {
// lib/graphql.js или src/lib/graphql.js
/** подключаем пост по slug */
export async function getPostBySlug(slug) {
const cacheKey = `post:${slug}`;
return await cache.wrap(
cacheKey,
async () => {
const query = `
query GetPostBySlug($slug: String!) {
profileArticleBy(slug: $slug) {
title
link
featuredImage {
node {
sourceUrl(size: LARGE)
altText
}
}
}
aNewBy(slug: $slug) {
title
link
featuredImage {
node {
sourceUrl(size: LARGE)
altText
}
}
}
}
`;
const data = await fetchGraphQL(query, { slug });
console.log('Raw GraphQL response:', JSON.stringify(data, null, 2));
// Находим первый существующий пост
const post = data.profileArticleBy || data.aNewBy;
if (!post) {
console.log('No post found for slug:', slug);
return null;
}
return {
title: post.title,
url: post.link,
image: post.featuredImage?.node?.sourceUrl || null,
imageAlt: post.featuredImage?.node?.altText || post.title || '',
type: data.profileArticleBy ? 'profile_article' : 'anew'
};
},
{ ttl: CACHE_TTL.POST_DETAIL }
);
}
/**
* Получить тег с постами по slug с пагинацией
*/