Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { createPage } from '@/app/_helpers';
import { getRouteOneNewsPage } from '@/shared/appLinks/RoutePaths';
import { getServerTranslation } from '@/shared/i18n';
import { defaultOpenGraph } from '@/shared/seoConstants';

export async function _getPage(lng: string, id: string) {
const { t } = await getServerTranslation(lng, 'news');
return createPage({
buildPage: () => ({}),
buildSeo: () => ({
title: t('head-title'),
description: t('head-description'),
keywords: t('head-keywords'),
openGraph: {
...defaultOpenGraph,
title: t('og-title'),
description: t('og-description'),
url: `/${lng}${getRouteOneNewsPage(id)}`,
},
alternates: {
canonical: `/${lng}${getRouteOneNewsPage(id)}`,
},
}),
});
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// import { withMetadataGenerator } from "@/app/_helpers";
export { NewsElementPage as default } from '@/preparedPages/NewsPages';
import { withPageData, withMetadataGenerator } from '@/app/_helpers';
import { _getPage } from './_getPage';
import { NewsElementPage } from '@/preparedPages/NewsPages';

// export const generateMetadata = withMetadataGenerator(_getPage);
export const generateMetadata = withMetadataGenerator(_getPage);
export default withPageData(NewsElementPage, _getPage);
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@
justify-content: center;
}

.noImageContainer {
position: relative;
width: 100%;
height: 2vh;
overflow: hidden;
flex-shrink: 0;
display: flex;
justify-content: center;
}


.image {
z-index: 1;
width: 30vw;
Expand Down Expand Up @@ -94,15 +105,17 @@
.text {
color: var(--white);
font: var(--font-dm-m);
line-height: 28px;
padding: 10px 5em;
text-align: center;
width: 100%;
text-align: left;
width: 80%;
Copy link
Member

Choose a reason for hiding this comment

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

Add breakpoint to keep width: 98% (to add very slight padding) on mobile and PR is good πŸ‘

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

white-space: pre-line;
}

@media (max-width: breakpoint(md)) {
.text {
padding: 10px 1em;
width: 98%;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use client';
import hannu from '@/shared/assets/images/heros/hannu-hodari/hannu-hodari.png';
import { Container } from '@/shared/ui/Container';
import { classNames } from '@/shared/lib/classNames/classNames';
import { useScrollToTop } from '@/shared/lib/hooks';
Expand Down Expand Up @@ -45,7 +44,7 @@ const NewsElementPage = () => {
const groupedNews = formatNews(moreNews, lngCode || 'fi-FI');
const picture = post.titlePicture?.id
? `${directusBaseUrl}/assets/${post.titlePicture.id}`
: hannu.src;
: undefined;
return (
<Container>
<div className={cls.navButtons}>
Expand Down Expand Up @@ -85,22 +84,27 @@ const NewsElementPage = () => {
</Button>
</div>
<div className={classNames(cls.NewsElementPage)}>
<div className={cls.imageContainer}>
<Image
src={picture}
alt={''}
className={cls.imageBlur}
width={100}
height={600}
/>
<Image
src={picture}
alt={''}
className={cls.image}
width={100}
height={600}
/>
</div>
{picture ? (
<div className={cls.imageContainer}>
<Image
src={picture}
alt={''}
className={cls.imageBlur}
width={100}
height={600}
/>
<Image
src={picture}
alt={''}
className={cls.image}
width={100}
height={600}
/>
</div>
) : (
<div className={cls.noImageContainer} />
)}

<h1 className={cls.title}>{post?.title}</h1>

<h3 className={cls.subtitle}>{post?.previewText}</h3>
Expand All @@ -125,7 +129,7 @@ const NewsElementPage = () => {
{groupedNews.map((news) => {
const imageSrc = news.titlePicture?.id
? `${directusBaseUrl}/assets/${news.titlePicture.id}`
: hannu.src;
: undefined;
return (
<NewsCard
key={news.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import cls from './NewsPage.module.scss';
import { useGetNewsQuery, formatNews } from '@/entities/NewsV2';
import { useParams } from 'next/navigation';
import { envHelper } from '@/shared/const/envHelper';
import hannu from '@/shared/assets/images/heros/hannu-hodari/hannu-hodari.png';
import { useGetTotalNewsCountQuery } from '@/entities/NewsV2/Api/newsApi';
import { useCallback, useEffect, useRef, useState } from 'react';
import { News } from '@/entities/NewsV2/model/types/types';
Expand Down Expand Up @@ -94,7 +93,7 @@ const NewsPage = () => {
{groupedNews.map((news) => {
const imageSrc = news.titlePicture?.id
? `${directusBaseUrl}/assets/${news.titlePicture.id}`
: hannu.src;
: undefined;
return (
<NewsCard
key={news.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { memo } from 'react';
import { classNames } from '@/shared/lib/classNames/classNames';
import cls from './NewsCard.module.scss';
import Image from 'next/image';
import hannu from '@/shared/assets/images/heros/hannu-hodari/hannu-hodari.png';
import Link from 'next/link';

interface NewsCardProps {
Expand All @@ -16,7 +15,7 @@ interface NewsCardProps {

const NewsCard = (props: NewsCardProps) => {
const { title, date, id, previewText, titlePicture } = props;
const picture = titlePicture || hannu.src;
const picture = titlePicture;
return (
<Link
rel="id"
Expand All @@ -29,15 +28,15 @@ const NewsCard = (props: NewsCardProps) => {
<p className={cls.text}>{previewText}</p>
<span className={cls.date}>{date}</span>
<div className={cls.imageContainer}>
<div className={cls.imageWrapper}>
{picture && (
<Image
src={picture}
alt={title}
className={cls.image}
width={100}
height={600}
/>
</div>
)}
</div>
</div>
</div>
Expand Down