Compare commits
No commits in common. "28f5babf2250d672df577d8050c1e04df19bc049" and "f7fe427aae98d3a33a713851aa0f4d80cb1f8b83" have entirely different histories.
28f5babf22
...
f7fe427aae
|
@ -1,40 +1,71 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
import {getTranslations, unstable_setRequestLocale} from 'next-intl/server';
|
import { unstable_setRequestLocale } from 'next-intl/server';
|
||||||
import { i18nText } from '../../../../i18nKeys';
|
import { i18nText } from '../../../../i18nKeys';
|
||||||
import {fetchBlogPosts} from "../../../../lib/contentful/blogPosts";
|
|
||||||
import Link from "next/link";
|
|
||||||
|
|
||||||
export default async function News({params: {locale}}: { params: { locale: string } }) {
|
export default function News({ params: { locale } }: { params: { locale: string }}) {
|
||||||
unstable_setRequestLocale(locale);
|
unstable_setRequestLocale(locale);
|
||||||
const t = await getTranslations('Main');
|
const t = useTranslations('Main');
|
||||||
const {data, total} = await fetchBlogPosts({preview: false, sticky: true})
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="main-articles">
|
<div className="main-articles">
|
||||||
<div className="b-inner">
|
<div className="b-inner">
|
||||||
<h2 className="title-h2">{t('news')}</h2>
|
<h2 className="title-h2">{t('news')}</h2>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
{data.map((item, i) => (
|
<div className="col-lg-4 col-md-6 col-sm-6">
|
||||||
<div className="col-lg-4 col-md-6 col-sm-6" key={'news' + i}>
|
<div className="b-article">
|
||||||
<div className="b-article">
|
<div className="b-article__image">
|
||||||
<div className="b-article__image">
|
<img className="" src="/images/article.png" alt=""/>
|
||||||
<img className="" src={item.listImage?.src} alt={item.listImage?.alt}/>
|
</div>
|
||||||
</div>
|
<div className="b-article__inner">
|
||||||
<div className="b-article__inner">
|
<div className="b-article__title">News Headline</div>
|
||||||
<div className="b-article__title">{item.title}</div>
|
<div className="b-article__text">
|
||||||
<div className="b-article__text">
|
The program not only focuses on a financial perspective, but allows you to study
|
||||||
{item.excerpt}
|
performance from many angles, such as human resources management, IT, operations
|
||||||
</div>
|
management, risks etc.
|
||||||
<Link href={`/${locale}/blog/${item.slug}`} className="b-article__link">
|
|
||||||
{i18nText('readMore', locale)}
|
|
||||||
<img className="" src="/images/chevron-forward.svg" alt=""/>
|
|
||||||
</Link>
|
|
||||||
</div>
|
</div>
|
||||||
|
<a href="#" className="b-article__link">{i18nText('readMore', locale)}
|
||||||
|
<img className="" src="/images/chevron-forward.svg" alt=""/>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
</div>
|
||||||
|
<div className="col-lg-4 d-none d-lg-block">
|
||||||
|
<div className="b-article">
|
||||||
|
<div className="b-article__image">
|
||||||
|
<img className="" src="/images/article.png" alt=""/>
|
||||||
|
</div>
|
||||||
|
<div className="b-article__inner">
|
||||||
|
<div className="b-article__title">News Headline</div>
|
||||||
|
<div className="b-article__text">
|
||||||
|
The program not only focuses on a financial perspective, but allows you to study
|
||||||
|
performance from many angles, such as human resources management, IT, operations
|
||||||
|
management, risks etc.
|
||||||
|
</div>
|
||||||
|
<a href="#" className="b-article__link">{i18nText('readMore', locale)}
|
||||||
|
<img className="" src="/images/chevron-forward.svg" alt=""/>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-lg-4 d-none d-lg-block">
|
||||||
|
<div className="b-article">
|
||||||
|
<div className="b-article__image">
|
||||||
|
<img className="" src="/images/article.png" alt=""/>
|
||||||
|
</div>
|
||||||
|
<div className="b-article__inner">
|
||||||
|
<div className="b-article__title">News Headline</div>
|
||||||
|
<div className="b-article__text">
|
||||||
|
The program not only focuses on a financial perspective, but allows you to study
|
||||||
|
performance from many angles, such as human resources management, IT, operations
|
||||||
|
management, risks etc.
|
||||||
|
</div>
|
||||||
|
<a href="#" className="b-article__link">{i18nText('readMore', locale)}
|
||||||
|
<img className="" src="/images/chevron-forward.svg" alt=""/>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import type {Metadata, ResolvingMetadata} from 'next';
|
import type { Metadata } from 'next';
|
||||||
import { draftMode } from 'next/headers'
|
import { draftMode } from 'next/headers'
|
||||||
import { notFound } from 'next/navigation';
|
import { notFound } from 'next/navigation';
|
||||||
import {fetchBlogPost, fetchBlogPosts, Widget} from "../../../../lib/contentful/blogPosts";
|
import {fetchBlogPost, fetchBlogPosts, Widget} from "../../../../lib/contentful/blogPosts";
|
||||||
|
@ -22,8 +22,7 @@ export async function generateMetadata({ params }: BlogPostPageProps, parent: Re
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: blogPost.title,
|
title: blogPost.title
|
||||||
description: blogPost.metaDescription
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,16 +68,15 @@ interface FetchBlogPostsOptions {
|
||||||
local?: string
|
local?: string
|
||||||
category?: string
|
category?: string
|
||||||
page?: number
|
page?: number
|
||||||
sticky?: boolean
|
|
||||||
}
|
}
|
||||||
export async function fetchBlogPosts({ preview, category, page, sticky }: FetchBlogPostsOptions): Promise<{
|
export async function fetchBlogPosts({ preview, category, page }: FetchBlogPostsOptions): Promise<{
|
||||||
total: number;
|
total: number;
|
||||||
data: BlogPost[]
|
data: BlogPost[]
|
||||||
}> {
|
}> {
|
||||||
const contentful = contentfulClient({ preview })
|
const contentful = contentfulClient({ preview })
|
||||||
const query = {
|
const query = {
|
||||||
content_type: 'blogPost',
|
content_type: 'blogPost',
|
||||||
select: ['fields.title', 'fields.excerpt', 'fields.author', 'fields.listImage', 'fields.author', 'fields.category', 'sys.createdAt', 'fields.slug', 'fields.metaDescription'],
|
select: ['fields.title', 'fields.excerpt', 'fields.author', 'fields.listImage', 'fields.author', 'fields.category', 'sys.createdAt', 'fields.slug'],
|
||||||
order: ['sys.createdAt'],
|
order: ['sys.createdAt'],
|
||||||
}
|
}
|
||||||
if (category){
|
if (category){
|
||||||
|
@ -85,18 +84,11 @@ export async function fetchBlogPosts({ preview, category, page, sticky }: FetchB
|
||||||
query['fields.category.sys.contentType.sys.id']='blogPostCategory'
|
query['fields.category.sys.contentType.sys.id']='blogPostCategory'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(page){
|
if(page){
|
||||||
query['limit'] = pageSize
|
query['limit'] = pageSize
|
||||||
query['skip'] = pageSize * (page - 1)
|
query['skip'] = pageSize * (page - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sticky){ // только три для главной
|
|
||||||
query['fields.sticky'] = 1
|
|
||||||
query['limit'] = 3
|
|
||||||
query['skip'] = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
const blogPostsResult = await contentful.getEntries<BlogPostSkeleton>(query)
|
const blogPostsResult = await contentful.getEntries<BlogPostSkeleton>(query)
|
||||||
|
|
||||||
const data = blogPostsResult.items.map((blogPostEntry) => parseContentfulBlogPost(blogPostEntry) as BlogPost)
|
const data = blogPostsResult.items.map((blogPostEntry) => parseContentfulBlogPost(blogPostEntry) as BlogPost)
|
||||||
|
|
|
@ -9,7 +9,6 @@ export interface BlogPostFields {
|
||||||
title?: EntryFieldTypes.Symbol
|
title?: EntryFieldTypes.Symbol
|
||||||
slug: EntryFieldTypes.Symbol
|
slug: EntryFieldTypes.Symbol
|
||||||
excerpt: EntryFieldTypes.Symbol
|
excerpt: EntryFieldTypes.Symbol
|
||||||
metaDescription: EntryFieldTypes.Symbol
|
|
||||||
listImage?: EntryFieldTypes.AssetLink
|
listImage?: EntryFieldTypes.AssetLink
|
||||||
author?: AuthorSkeleton
|
author?: AuthorSkeleton
|
||||||
category: BlogPostCategorySkeleton
|
category: BlogPostCategorySkeleton
|
||||||
|
@ -29,7 +28,6 @@ export interface BlogPost {
|
||||||
author: Author | null
|
author: Author | null
|
||||||
category: string
|
category: string
|
||||||
createdAt: string
|
createdAt: string
|
||||||
metaDescription: string
|
|
||||||
body: Array<WidgetMedia | WidgetParagraph>
|
body: Array<WidgetMedia | WidgetParagraph>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue