Files
profile-front/src/pages/author/[slug]/index.astro
2026-03-02 23:10:31 +03:00

78 lines
1.8 KiB
Plaintext

---
import MainLayout from '@layouts/MainLayout.astro';
import { getAuthorData, getPostsByCoauthorLogin } from '@lib/api/authors';
import ContentGrid from '@components/ContentGrid.astro';
export const prerender = false;
const { slug } = Astro.params;
const author = await getAuthorData(slug);
const data = await getPostsByCoauthorLogin(slug);
const posts = data.posts;
// Если автор не найден - 404
//if (!authorData) {
// return Astro.redirect('/404');
//}
---
<MainLayout
title={`Публикации автора: ${slug}`}
description={`Информационное агентство Деловой журнал Профиль - записи по тегу ${slug}`}
>
{author && (
<div class="author-card">
{author.avatar && (
<img
src={author.avatar}
alt={author.name}
width="192"
height="192"
class="avatar"
/>
)}
<h1>{author.name}</h1>
{(author.firstName || author.lastName) && (
<p class="full-name">
{author.firstName} {author.lastName}
</p>
)}
{author.bio && (
<div class="bio">{author.bio}</div>
)}
{author.social && Object.values(author.social).some(Boolean) && (
<div class="social-links">
{author.social.twitter && (
<a href={author.social.twitter}>Twitter</a>
)}
{author.social.facebook && (
<a href={author.social.facebook}>Facebook</a>
)}
{author.social.instagram && (
<a href={author.social.instagram}>Instagram</a>
)}
</div>
)}
</div>
)}
<ContentGrid
items={posts}
pageInfo={data.pageInfo}
slug={slug}
showCount={false}
type='author'
perLoad={11}
/>
</MainLayout>