Skip to content

Commit

Permalink
Make separate component for latest articles
Browse files Browse the repository at this point in the history
  • Loading branch information
deadrime committed Feb 24, 2024
1 parent 54bd0bd commit e16e0c9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
19 changes: 1 addition & 18 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Metadata } from 'next';
import { getPaginatedArticles } from '@/helpers/blog';
import { BlogArticle } from '@/components/Article';
import AboutSection from '@/components/AboutSection/AboutSection';
import Technologies from '@/components/Technologies/Technologies';
import MyExperience from '@/components/MyExperience/MyExperience';
import LatestArticles from '@/components/LatestArticles/LatestArticles';

export const metadata: Metadata = {
metadataBase: process.env.NODE_ENV === 'development' ? new URL('http://localhost:3000') : new URL('https://zhenya.dev'),
Expand All @@ -30,22 +29,6 @@ const jsonLd = {
"sameAs": ["deadrime"]
}

const LatestArticles = async () => {
const { articles, totalCount } = await getPaginatedArticles(3);

return (
<section className="mt-12 md:mt-40">
<h2 className="font-primary text-xl font-normal block mb-11">
Блог
</h2>
<div className="grid gap-5" style={{
gridTemplateColumns: 'repeat(auto-fit, minmax(380px, 1fr))'
}}>
{articles.map(article => <BlogArticle key={article.slug} article={article} />)}
</div>
</section>
)
}

export default async function Home() {
return (
Expand Down
9 changes: 9 additions & 0 deletions components/LatestArticles/LatestArticles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.articlesWrapper {
display: grid;
gap: 1.25rem;
grid-template-columns: 1fr;

@media screen(md) {
grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
}
}
21 changes: 21 additions & 0 deletions components/LatestArticles/LatestArticles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { getPaginatedArticles } from "@/helpers/blog";
import { BlogArticle } from "../Article";
import styles from './LatestArticles.module.css';
import classNames from "classnames";

const LatestArticles = async () => {
const { articles, totalCount } = await getPaginatedArticles(3);

return (
<section className="mt-12 md:mt-40">
<h2 className="font-primary text-xl font-normal block mb-11">
Блог
</h2>
<div className={styles.articlesWrapper}>
{articles.map(article => <BlogArticle key={article.slug} article={article} />)}
</div>
</section>
)
}

export default LatestArticles;

0 comments on commit e16e0c9

Please sign in to comment.