Skip to content

Commit

Permalink
Merge pull request #546 from seregad544/author_pages
Browse files Browse the repository at this point in the history
[#543] add author page
  • Loading branch information
dzencot authored Nov 25, 2022
2 parents c8bf2b3 + e52166f commit 749f232
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
44 changes: 44 additions & 0 deletions components/AuthorPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import Image from 'next/image';
import { useTranslation } from 'next-i18next';

import Post from './Post.jsx';

const AuthorPage = ({ author, avatar, description, posts }) => {
const { t } = useTranslation('author');

const postsList = posts.filter((post) => post.author === author).map((post) =>
<div key={post.name} className="mb-4">
<Post post={post} />
</div>
);

return (
<div className="row mx-lg-5">
<div className="col-md-4 mb-5">
<div className="card">
<div className="card-block">
<Image
className="rounded-circle"
src={avatar}
alt="avatar"
width={300}
height={300}
/>
<h2>{author}</h2>
<p className="card-text text-muted">
{description}
</p>
</div>
</div>
</div>
<div className="col-md-8">
<h2>{t('publications')}</h2>
<hr/>
{postsList}
</div>
</div>
);
};

export default AuthorPage;
2 changes: 1 addition & 1 deletion next-i18next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ module.exports = {
defaultLocale: 'en',
locales: [ 'ru', 'en' ],
},
ns: ['common', 'about', 'post', '404'],
ns: ['common', 'about', 'post', '404', 'author'],
};
3 changes: 3 additions & 0 deletions public/locales/en/author.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"publications": "Publications"
}
3 changes: 3 additions & 0 deletions public/locales/ru/author.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"publications": "Публикации"
}

1 comment on commit 749f232

@vercel
Copy link

@vercel vercel bot commented on 749f232 Nov 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

hexletguides – ./

hexletguides-hexlet.vercel.app
hexletguides-git-main-hexlet.vercel.app
guides.hexlet.io

Please sign in to comment.