summaryrefslogtreecommitdiffstats
path: root/src/components/organisms/layout
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/organisms/layout')
-rw-r--r--src/components/organisms/layout/cards-list.stories.tsx16
-rw-r--r--src/components/organisms/layout/cards-list.test.tsx26
-rw-r--r--src/components/organisms/layout/comment.module.scss12
-rw-r--r--src/components/organisms/layout/comment.test.tsx2
-rw-r--r--src/components/organisms/layout/comment.tsx83
-rw-r--r--src/components/organisms/layout/overview.module.scss34
-rw-r--r--src/components/organisms/layout/overview.stories.tsx29
-rw-r--r--src/components/organisms/layout/overview.test.tsx19
-rw-r--r--src/components/organisms/layout/overview.tsx41
-rw-r--r--src/components/organisms/layout/posts-list.stories.tsx80
-rw-r--r--src/components/organisms/layout/posts-list.test.tsx76
-rw-r--r--src/components/organisms/layout/posts-list.tsx2
-rw-r--r--src/components/organisms/layout/summary.module.scss13
-rw-r--r--src/components/organisms/layout/summary.stories.tsx33
-rw-r--r--src/components/organisms/layout/summary.test.tsx27
-rw-r--r--src/components/organisms/layout/summary.tsx33
16 files changed, 281 insertions, 245 deletions
diff --git a/src/components/organisms/layout/cards-list.stories.tsx b/src/components/organisms/layout/cards-list.stories.tsx
index fe0ebfd..522d068 100644
--- a/src/components/organisms/layout/cards-list.stories.tsx
+++ b/src/components/organisms/layout/cards-list.stories.tsx
@@ -93,9 +93,7 @@ const items: CardsListItem[] = [
// @ts-ignore - Needed because of the placeholder image.
unoptimized: true,
},
- meta: [
- { id: 'meta-1', term: 'Quibusdam', value: ['Velit', 'Ex', 'Alias'] },
- ],
+ meta: { thematics: ['Velit', 'Ex', 'Alias'] },
tagline: 'Molestias ut error',
title: 'Et alias omnis',
url: '#',
@@ -110,7 +108,7 @@ const items: CardsListItem[] = [
// @ts-ignore - Needed because of the placeholder image.
unoptimized: true,
},
- meta: [{ id: 'meta-1', term: 'Est', value: ['Voluptas'] }],
+ meta: { thematics: ['Voluptas'] },
tagline: 'Quod vel accusamus',
title: 'Laboriosam doloremque mollitia',
url: '#',
@@ -125,13 +123,9 @@ const items: CardsListItem[] = [
// @ts-ignore - Needed because of the placeholder image.
unoptimized: true,
},
- meta: [
- {
- id: 'meta-1',
- term: 'Omnis',
- value: ['Quisquam', 'Quia', 'Sapiente', 'Perspiciatis'],
- },
- ],
+ meta: {
+ thematics: ['Quisquam', 'Quia', 'Sapiente', 'Perspiciatis'],
+ },
tagline: 'Quo error eum',
title: 'Magni rem nulla',
url: '#',
diff --git a/src/components/organisms/layout/cards-list.test.tsx b/src/components/organisms/layout/cards-list.test.tsx
index 2df3f59..7d98844 100644
--- a/src/components/organisms/layout/cards-list.test.tsx
+++ b/src/components/organisms/layout/cards-list.test.tsx
@@ -1,7 +1,7 @@
import { render, screen } from '@test-utils';
-import CardsList from './cards-list';
+import CardsList, { type CardsListItem } from './cards-list';
-const items = [
+const items: CardsListItem[] = [
{
id: 'card-1',
cover: {
@@ -9,10 +9,10 @@ const items = [
src: 'http://placeimg.com/640/480',
width: 640,
height: 480,
+ // @ts-ignore - Needed because of the placeholder image.
+ unoptimized: true,
},
- meta: [
- { id: 'meta-1', term: 'Quibusdam', value: ['Velit', 'Ex', 'Alias'] },
- ],
+ meta: { thematics: ['Velit', 'Ex', 'Alias'] },
tagline: 'Molestias ut error',
title: 'Et alias omnis',
url: '#',
@@ -24,8 +24,10 @@ const items = [
src: 'http://placeimg.com/640/480',
width: 640,
height: 480,
+ // @ts-ignore - Needed because of the placeholder image.
+ unoptimized: true,
},
- meta: [{ id: 'meta-1', term: 'Est', value: ['Voluptas'] }],
+ meta: { thematics: ['Voluptas'] },
tagline: 'Quod vel accusamus',
title: 'Laboriosam doloremque mollitia',
url: '#',
@@ -37,14 +39,12 @@ const items = [
src: 'http://placeimg.com/640/480',
width: 640,
height: 480,
+ // @ts-ignore - Needed because of the placeholder image.
+ unoptimized: true,
+ },
+ meta: {
+ thematics: ['Quisquam', 'Quia', 'Sapiente', 'Perspiciatis'],
},
- meta: [
- {
- id: 'meta-1',
- term: 'Omnis',
- value: ['Quisquam', 'Quia', 'Sapiente', 'Perspiciatis'],
- },
- ],
tagline: 'Quo error eum',
title: 'Magni rem nulla',
url: '#',
diff --git a/src/components/organisms/layout/comment.module.scss b/src/components/organisms/layout/comment.module.scss
index 54201de..d2b68e1 100644
--- a/src/components/organisms/layout/comment.module.scss
+++ b/src/components/organisms/layout/comment.module.scss
@@ -60,16 +60,20 @@
}
.date {
- flex-flow: row wrap;
- justify-content: center;
margin: var(--spacing-sm) 0;
font-size: var(--font-size-sm);
- text-align: center;
+
+ &__item {
+ justify-content: center;
+ }
@include mix.media("screen") {
@include mix.dimensions("sm") {
- justify-content: left;
margin: 0 0 var(--spacing-sm);
+
+ &__item {
+ justify-content: left;
+ }
}
}
}
diff --git a/src/components/organisms/layout/comment.test.tsx b/src/components/organisms/layout/comment.test.tsx
index 9e537e5..4961722 100644
--- a/src/components/organisms/layout/comment.test.tsx
+++ b/src/components/organisms/layout/comment.test.tsx
@@ -1,5 +1,5 @@
import { render, screen } from '@test-utils';
-import { getFormattedDate, getFormattedTime } from '@utils/helpers/format';
+import { getFormattedDate, getFormattedTime } from '@utils/helpers/dates';
import Comment from './comment';
const author = {
diff --git a/src/components/organisms/layout/comment.tsx b/src/components/organisms/layout/comment.tsx
index 6d41c00..248efc2 100644
--- a/src/components/organisms/layout/comment.tsx
+++ b/src/components/organisms/layout/comment.tsx
@@ -1,10 +1,12 @@
import Button from '@components/atoms/buttons/button';
import Link from '@components/atoms/links/link';
-import DescriptionList from '@components/atoms/lists/description-list';
-import { getFormattedDate, getFormattedTime } from '@utils/helpers/format';
+import Meta from '@components/molecules/layout/meta';
+import useSettings from '@utils/hooks/use-settings';
import Image from 'next/image';
+import Script from 'next/script';
import { FC, useState } from 'react';
import { useIntl } from 'react-intl';
+import { type Comment as CommentSchema, type WithContext } from 'schema-dts';
import CommentForm, { type CommentFormProps } from '../forms/comment-form';
import styles from './comment.module.scss';
@@ -41,7 +43,11 @@ export type CommentProps = {
*/
id: number | string;
/**
- * The comment date.
+ * The comment parent id.
+ */
+ parentId?: number | string;
+ /**
+ * The comment date and time separated with a space.
*/
publication: string;
/**
@@ -60,15 +66,14 @@ const Comment: FC<CommentProps> = ({
canReply = true,
content,
id,
+ parentId,
publication,
saveComment,
...props
}) => {
const intl = useIntl();
const [isReplying, setIsReplying] = useState<boolean>(false);
- const commentDate = getFormattedDate(publication);
- const commentTime = getFormattedTime(publication);
- const commentDateTime = new Date(publication).toISOString();
+ const [publicationDate, publicationTime] = publication.split(' ');
const avatarAltText = intl.formatMessage(
{
@@ -89,37 +94,46 @@ const Comment: FC<CommentProps> = ({
description: 'Comment: reply button',
id: 'hzHuCc',
});
- const dateLabel = intl.formatMessage({
- defaultMessage: 'Published on:',
- description: 'Comment: publication date label',
- id: 'soj7do',
- });
- const dateValue = intl.formatMessage(
- {
- defaultMessage: '{date} at {time}',
- description: 'Comment: publication date and time',
- id: 'Ld6yMP',
- },
- {
- date: commentDate,
- time: commentTime,
- }
- );
const formTitle = intl.formatMessage({
defaultMessage: 'Leave a reply',
description: 'Comment: comment form title',
id: '2fD5CI',
});
- const dateLink = (
- <Link href={`#comment-${id}`}>
- <time dateTime={commentDateTime}></time>
- {dateValue}
- </Link>
- );
+ const { website } = useSettings();
+
+ const commentSchema: WithContext<CommentSchema> = {
+ '@context': 'https://schema.org',
+ '@id': `${website.url}/#comment-${id}`,
+ '@type': 'Comment',
+ parentItem: parentId
+ ? { '@id': `${website.url}/#comment-${parentId}` }
+ : undefined,
+ about: { '@type': 'Article', '@id': `${website.url}/#article` },
+ author: {
+ '@type': 'Person',
+ name: author.name,
+ image: author.avatar,
+ url: author.url,
+ },
+ creator: {
+ '@type': 'Person',
+ name: author.name,
+ image: author.avatar,
+ url: author.url,
+ },
+ dateCreated: publication,
+ datePublished: publication,
+ text: content,
+ };
return (
<>
+ <Script
+ id="schema-comments"
+ type="application/ld+json"
+ dangerouslySetInnerHTML={{ __html: JSON.stringify(commentSchema) }}
+ />
<article
id={`comment-${id}`}
className={`${styles.wrapper} ${styles['wrapper--comment']}`}
@@ -142,11 +156,18 @@ const Comment: FC<CommentProps> = ({
<span className={styles.author}>{author.name}</span>
)}
</header>
- <DescriptionList
- items={[{ id: 'comment-date', term: dateLabel, value: [dateLink] }]}
+ <Meta
+ data={{
+ publication: {
+ date: publicationDate,
+ time: publicationTime,
+ target: `#comment-${id}`,
+ },
+ }}
layout="inline"
+ itemsLayout="inline"
className={styles.date}
- groupClassName={styles.meta}
+ groupClassName={styles.date__item}
/>
<div className={styles.body}>{content}</div>
<footer className={styles.footer}>
diff --git a/src/components/organisms/layout/overview.module.scss b/src/components/organisms/layout/overview.module.scss
index 4d50ad1..e813625 100644
--- a/src/components/organisms/layout/overview.module.scss
+++ b/src/components/organisms/layout/overview.module.scss
@@ -1,12 +1,44 @@
@use "@styles/abstracts/functions" as fun;
+@use "@styles/abstracts/mixins" as mix;
.wrapper {
padding: var(--spacing-sm) var(--spacing-md);
border: fun.convert-px(1) solid var(--color-border);
+
+ .meta {
+ display: grid;
+ grid-template-columns: repeat(
+ auto-fit,
+ min(calc(100vw - (var(--spacing-md) * 2)), 23ch)
+ );
+ row-gap: var(--spacing-2xs);
+
+ @include mix.media("screen") {
+ @include mix.dimensions("md") {
+ grid-template-columns: repeat(
+ auto-fit,
+ min(calc(100vw - (var(--spacing-md) * 2)), 20ch)
+ );
+ }
+ }
+
+ &--has-techno {
+ div:last-child {
+ gap: var(--spacing-2xs);
+
+ dd {
+ padding: 0 var(--spacing-2xs);
+ border: fun.convert-px(1) solid var(--color-border-dark);
+ }
+ }
+ }
+ }
}
.cover {
- max-height: fun.convert-px(150);
+ width: 100%;
+ height: fun.convert-px(175);
margin: 0 auto var(--spacing-md);
+ padding: var(--spacing-2xs);
border: fun.convert-px(1) solid var(--color-border);
}
diff --git a/src/components/organisms/layout/overview.stories.tsx b/src/components/organisms/layout/overview.stories.tsx
index b18a6b6..1139350 100644
--- a/src/components/organisms/layout/overview.stories.tsx
+++ b/src/components/organisms/layout/overview.stories.tsx
@@ -1,5 +1,5 @@
import { ComponentMeta, ComponentStory } from '@storybook/react';
-import Overview from './overview';
+import Overview, { OverviewMeta } from './overview';
/**
* Overview - Storybook Meta
@@ -8,8 +8,21 @@ export default {
title: 'Organisms/Layout/Overview',
component: Overview,
argTypes: {
+ className: {
+ control: {
+ type: 'text',
+ },
+ description: 'Set additional classnames to the overview wrapper.',
+ table: {
+ category: 'Styles',
+ },
+ type: {
+ name: 'string',
+ required: false,
+ },
+ },
cover: {
- description: 'The overview cover.',
+ description: 'The overview cover',
table: {
category: 'Options',
},
@@ -20,7 +33,7 @@ export default {
},
},
meta: {
- description: 'The overview metadata.',
+ description: 'The overview meta.',
type: {
name: 'object',
required: true,
@@ -42,12 +55,9 @@ const cover = {
unoptimized: true,
};
-const meta = {
- publication: { name: 'Illo ut odio:', value: 'Sequi et excepturi' },
- update: {
- name: 'Perspiciatis vel laudantium:',
- value: 'Dignissimos ratione veritatis',
- },
+const meta: OverviewMeta = {
+ creation: { date: '2022-05-09' },
+ license: 'Dignissimos ratione veritatis',
};
/**
@@ -55,7 +65,6 @@ const meta = {
*/
export const Default = Template.bind({});
Default.args = {
- cover,
meta,
};
diff --git a/src/components/organisms/layout/overview.test.tsx b/src/components/organisms/layout/overview.test.tsx
index 0738d3f..b40a785 100644
--- a/src/components/organisms/layout/overview.test.tsx
+++ b/src/components/organisms/layout/overview.test.tsx
@@ -1,5 +1,5 @@
import { render, screen } from '@test-utils';
-import Overview from './overview';
+import Overview, { type OverviewMeta } from './overview';
const cover = {
alt: 'Incidunt unde quam',
@@ -8,22 +8,19 @@ const cover = {
width: 640,
};
-const meta = {
- publication: { name: 'Illo ut odio:', value: 'Sequi et excepturi' },
- update: {
- name: 'Perspiciatis vel laudantium:',
- value: 'Dignissimos ratione veritatis',
- },
+const data: OverviewMeta = {
+ creation: { date: '2022-05-09' },
+ license: 'Dignissimos ratione veritatis',
};
describe('Overview', () => {
- it('renders some meta', () => {
- render(<Overview meta={meta} />);
- expect(screen.getByText(meta['publication'].name)).toBeInTheDocument();
+ it('renders some data', () => {
+ render(<Overview meta={data} />);
+ expect(screen.getByText(data.license!)).toBeInTheDocument();
});
it('renders a cover', () => {
- render(<Overview meta={meta} cover={cover} />);
+ render(<Overview cover={cover} meta={data} />);
expect(screen.getByRole('img', { name: cover.alt })).toBeInTheDocument();
});
});
diff --git a/src/components/organisms/layout/overview.tsx b/src/components/organisms/layout/overview.tsx
index 42d0431..55ad0b5 100644
--- a/src/components/organisms/layout/overview.tsx
+++ b/src/components/organisms/layout/overview.tsx
@@ -1,13 +1,33 @@
import ResponsiveImage, {
type ResponsiveImageProps,
} from '@components/molecules/images/responsive-image';
-import Meta, { type MetaMap } from '@components/molecules/layout/meta';
+import Meta, { type MetaData } from '@components/molecules/layout/meta';
import { FC } from 'react';
import styles from './overview.module.scss';
+export type OverviewMeta = Pick<
+ MetaData,
+ | 'creation'
+ | 'license'
+ | 'popularity'
+ | 'repositories'
+ | 'technologies'
+ | 'update'
+>;
+
export type OverviewProps = {
+ /**
+ * Set additional classnames to the overview wrapper.
+ */
+ className?: string;
+ /**
+ * The overview cover.
+ */
cover?: Pick<ResponsiveImageProps, 'alt' | 'src' | 'width' | 'height'>;
- meta: MetaMap;
+ /**
+ * The overview meta.
+ */
+ meta: OverviewMeta;
};
/**
@@ -15,17 +35,26 @@ export type OverviewProps = {
*
* Render an overview.
*/
-const Overview: FC<OverviewProps> = ({ cover, meta }) => {
+const Overview: FC<OverviewProps> = ({ className = '', cover, meta }) => {
+ const { technologies, ...remainingMeta } = meta;
+ const metaModifier = technologies ? styles['meta--has-techno'] : '';
+
return (
- <div className={styles.wrapper}>
+ <div className={`${styles.wrapper} ${className}`}>
{cover && (
<ResponsiveImage
- objectFit="cover"
+ layout="responsive"
+ objectFit="contain"
className={styles.cover}
{...cover}
/>
)}
- <Meta data={meta} layout="column" responsiveLayout={true} />
+ <Meta
+ data={{ ...remainingMeta, technologies }}
+ layout="inline"
+ className={`${styles.meta} ${metaModifier}`}
+ withSeparator={false}
+ />
</div>
);
};
diff --git a/src/components/organisms/layout/posts-list.stories.tsx b/src/components/organisms/layout/posts-list.stories.tsx
index f80e1ca..d97ad03 100644
--- a/src/components/organisms/layout/posts-list.stories.tsx
+++ b/src/components/organisms/layout/posts-list.stories.tsx
@@ -1,5 +1,4 @@
import { ComponentMeta, ComponentStory } from '@storybook/react';
-import { IntlProvider } from 'react-intl';
import PostsList, { type Post } from './posts-list';
/**
@@ -51,13 +50,6 @@ export default {
},
},
},
- decorators: [
- (Story) => (
- <IntlProvider locale="en">
- <Story />
- </IntlProvider>
- ),
- ],
} as ComponentMeta<typeof PostsList>;
const Template: ComponentStory<typeof PostsList> = (args) => (
@@ -70,23 +62,17 @@ const posts: Post[] = [
'Esse et voluptas sapiente modi impedit unde et. Ducimus nulla ea impedit sit placeat nihil assumenda. Rem est fugiat amet quo hic. Corrupti fuga quod animi autem dolorem ullam corrupti vel aut.',
id: 'post-1',
meta: {
- publication: {
- name: 'Published on:',
- value: '2022-02-26T00:42:02',
- },
- readingTime: { name: 'Reading time:', value: '5 minutes' },
- categories: {
- name: 'Categories:',
- value: [
- <a key="cat-1" href="#">
- Cat 1
- </a>,
- <a key="cat-2" href="#">
- Cat 2
- </a>,
- ],
- },
- comments: { name: 'Comments:', value: '1 comment' },
+ publication: { date: '2022-02-26' },
+ readingTime: '5 minutes',
+ thematics: [
+ <a key="cat-1" href="#">
+ Cat 1
+ </a>,
+ <a key="cat-2" href="#">
+ Cat 2
+ </a>,
+ ],
+ commentsCount: '1 comment',
},
title: 'Ratione velit fuga',
url: '#',
@@ -104,20 +90,14 @@ const posts: Post[] = [
'Illum quae asperiores quod aut necessitatibus itaque excepturi voluptas. Incidunt exercitationem ullam saepe alias consequatur sed. Quam veniam quaerat voluptatum earum quia quisquam fugiat sed perspiciatis. Et velit saepe est recusandae facilis eos eum ipsum.',
id: 'post-2',
meta: {
- publication: {
- name: 'Published on:',
- value: '2022-02-20T10:40:00',
- },
- readingTime: { name: 'Reading time:', value: '8 minutes' },
- categories: {
- name: 'Categories:',
- value: [
- <a key="cat-2" href="#">
- Cat 2
- </a>,
- ],
- },
- comments: { name: 'Comments:', value: '0 comments' },
+ publication: { date: '2022-02-20' },
+ readingTime: '8 minutes',
+ thematics: [
+ <a key="cat-2" href="#">
+ Cat 2
+ </a>,
+ ],
+ commentsCount: '0 comments',
},
title: 'Debitis laudantium laudantium',
url: '#',
@@ -127,20 +107,14 @@ const posts: Post[] = [
'Sunt aperiam ut rem impedit dolor id sit. Reprehenderit ipsum iusto fugiat. Quaerat laboriosam magnam facilis. Totam sint aliquam voluptatem in quis laborum sunt eum. Enim aut debitis officiis porro iure quia nihil voluptas ipsum. Praesentium quis necessitatibus cumque quia qui velit quos dolorem.',
id: 'post-3',
meta: {
- publication: {
- name: 'Published on:',
- value: '2021-12-20T15:12:02',
- },
- readingTime: { name: 'Reading time:', value: '3 minutes' },
- categories: {
- name: 'Categories:',
- value: [
- <a key="cat-1" href="#">
- Cat 1
- </a>,
- ],
- },
- comments: { name: 'Comments:', value: '3 comments' },
+ publication: { date: '2021-12-20' },
+ readingTime: '3 minutes',
+ thematics: [
+ <a key="cat-1" href="#">
+ Cat 1
+ </a>,
+ ],
+ commentsCount: '3 comments',
},
title: 'Quaerat ut corporis',
url: '#',
diff --git a/src/components/organisms/layout/posts-list.test.tsx b/src/components/organisms/layout/posts-list.test.tsx
index aa6dffa..98af1c3 100644
--- a/src/components/organisms/layout/posts-list.test.tsx
+++ b/src/components/organisms/layout/posts-list.test.tsx
@@ -1,29 +1,23 @@
import { render, screen } from '@test-utils';
-import PostsList from './posts-list';
+import PostsList, { Post } from './posts-list';
-const posts = [
+const posts: Post[] = [
{
excerpt:
'Esse et voluptas sapiente modi impedit unde et. Ducimus nulla ea impedit sit placeat nihil assumenda. Rem est fugiat amet quo hic. Corrupti fuga quod animi autem dolorem ullam corrupti vel aut.',
id: 'post-1',
meta: {
- publication: {
- name: 'Published on:',
- value: '2022-02-26T00:42:02',
- },
- readingTime: { name: 'Reading time:', value: '5 minutes' },
- categories: {
- name: 'Categories:',
- value: [
- <a key="cat-1" href="#">
- Cat 1
- </a>,
- <a key="cat-2" href="#">
- Cat 2
- </a>,
- ],
- },
- comments: { name: 'Comments:', value: '1 comment' },
+ publication: { date: '2022-02-26' },
+ readingTime: '5 minutes',
+ thematics: [
+ <a key="cat-1" href="#">
+ Cat 1
+ </a>,
+ <a key="cat-2" href="#">
+ Cat 2
+ </a>,
+ ],
+ commentsCount: '1 comment',
},
title: 'Ratione velit fuga',
url: '#',
@@ -39,20 +33,14 @@ const posts = [
'Illum quae asperiores quod aut necessitatibus itaque excepturi voluptas. Incidunt exercitationem ullam saepe alias consequatur sed. Quam veniam quaerat voluptatum earum quia quisquam fugiat sed perspiciatis. Et velit saepe est recusandae facilis eos eum ipsum.',
id: 'post-2',
meta: {
- publication: {
- name: 'Published on:',
- value: '2022-02-20T10:40:00',
- },
- readingTime: { name: 'Reading time:', value: '8 minutes' },
- categories: {
- name: 'Categories:',
- value: [
- <a key="cat-2" href="#">
- Cat 2
- </a>,
- ],
- },
- comments: { name: 'Comments:', value: '0 comments' },
+ publication: { date: '2022-02-20' },
+ readingTime: '8 minutes',
+ thematics: [
+ <a key="cat-2" href="#">
+ Cat 2
+ </a>,
+ ],
+ commentsCount: '0 comments',
},
title: 'Debitis laudantium laudantium',
url: '#',
@@ -62,20 +50,14 @@ const posts = [
'Sunt aperiam ut rem impedit dolor id sit. Reprehenderit ipsum iusto fugiat. Quaerat laboriosam magnam facilis. Totam sint aliquam voluptatem in quis laborum sunt eum. Enim aut debitis officiis porro iure quia nihil voluptas ipsum. Praesentium quis necessitatibus cumque quia qui velit quos dolorem.',
id: 'post-3',
meta: {
- publication: {
- name: 'Published on:',
- value: '2021-12-20T15:12:02',
- },
- readingTime: { name: 'Reading time:', value: '3 minutes' },
- categories: {
- name: 'Categories:',
- value: [
- <a key="cat-1" href="#">
- Cat 1
- </a>,
- ],
- },
- comments: { name: 'Comments:', value: '3 comments' },
+ publication: { date: '2021-12-20' },
+ readingTime: '3 minutes',
+ thematics: [
+ <a key="cat-1" href="#">
+ Cat 1
+ </a>,
+ ],
+ commentsCount: '3 comments',
},
title: 'Quaerat ut corporis',
url: '#',
diff --git a/src/components/organisms/layout/posts-list.tsx b/src/components/organisms/layout/posts-list.tsx
index d67b03a..4855205 100644
--- a/src/components/organisms/layout/posts-list.tsx
+++ b/src/components/organisms/layout/posts-list.tsx
@@ -40,7 +40,7 @@ const sortPostsByYear = (data: Post[]): YearCollection => {
const yearCollection: YearCollection = {};
data.forEach((post) => {
- const postYear = new Date(post.meta.publication.value as string)
+ const postYear = new Date(post.meta.publication!.date)
.getFullYear()
.toString();
yearCollection[postYear] = [...(yearCollection[postYear] || []), post];
diff --git a/src/components/organisms/layout/summary.module.scss b/src/components/organisms/layout/summary.module.scss
index 1cdda98..6d19853 100644
--- a/src/components/organisms/layout/summary.module.scss
+++ b/src/components/organisms/layout/summary.module.scss
@@ -83,5 +83,18 @@
}
.meta {
+ display: grid;
+ grid-template-columns: repeat(
+ auto-fit,
+ min(100vw, calc(50% - var(--spacing-lg)))
+ );
+ margin-top: var(--spacing-lg);
font-size: var(--font-size-sm);
+
+ @include mix.media("screen") {
+ @include mix.dimensions("sm") {
+ display: flex;
+ margin-top: 0;
+ }
+ }
}
diff --git a/src/components/organisms/layout/summary.stories.tsx b/src/components/organisms/layout/summary.stories.tsx
index 05be7da..42f1d44 100644
--- a/src/components/organisms/layout/summary.stories.tsx
+++ b/src/components/organisms/layout/summary.stories.tsx
@@ -1,5 +1,4 @@
import { ComponentMeta, ComponentStory } from '@storybook/react';
-import { IntlProvider } from 'react-intl';
import Summary from './summary';
/**
@@ -78,13 +77,6 @@ export default {
},
},
},
- decorators: [
- (Story) => (
- <IntlProvider locale="en">
- <Story />
- </IntlProvider>
- ),
- ],
} as ComponentMeta<typeof Summary>;
const Template: ComponentStory<typeof Summary> = (args) => (
@@ -100,20 +92,17 @@ const cover = {
};
const meta = {
- publication: { name: 'Published on:', value: 'April 11th 2022' },
- readingTime: { name: 'Reading time:', value: '5 minutes' },
- categories: {
- name: 'Categories:',
- value: [
- <a key="cat-1" href="#">
- Cat 1
- </a>,
- <a key="cat-2" href="#">
- Cat 2
- </a>,
- ],
- },
- comments: { name: 'Comments:', value: '1 comment' },
+ publication: { date: '2022-04-11' },
+ readingTime: '5 minutes',
+ thematics: [
+ <a key="cat-1" href="#">
+ Cat 1
+ </a>,
+ <a key="cat-2" href="#">
+ Cat 2
+ </a>,
+ ],
+ commentsCount: '1 comment',
};
/**
diff --git a/src/components/organisms/layout/summary.test.tsx b/src/components/organisms/layout/summary.test.tsx
index 4944805..09b797c 100644
--- a/src/components/organisms/layout/summary.test.tsx
+++ b/src/components/organisms/layout/summary.test.tsx
@@ -12,20 +12,17 @@ const excerpt =
'Perspiciatis quasi libero nemo non eligendi nam minima. Deleniti expedita tempore. Praesentium explicabo molestiae eaque consectetur vero. Quae nostrum quisquam similique. Ut hic est quas ut esse quisquam nobis.';
const meta = {
- publication: { name: 'Published on:', value: 'April 11th 2022' },
- readingTime: { name: 'Reading time:', value: '5 minutes' },
- categories: {
- name: 'Categories:',
- value: [
- <a key="cat-1" href="#">
- Cat 1
- </a>,
- <a key="cat-2" href="#">
- Cat 2
- </a>,
- ],
- },
- comments: { name: 'Comments:', value: '1 comment' },
+ publication: { date: '2022-04-11' },
+ readingTime: '5 minutes',
+ thematics: [
+ <a key="cat-1" href="#">
+ Cat 1
+ </a>,
+ <a key="cat-2" href="#">
+ Cat 2
+ </a>,
+ ],
+ commentsCount: '1 comment',
};
const title = 'Odio odit necessitatibus';
@@ -80,6 +77,6 @@ describe('Summary', () => {
it('renders some meta', () => {
render(<Summary excerpt={excerpt} meta={meta} title={title} url={url} />);
- expect(screen.getByText(meta.publication.name)).toBeInTheDocument();
+ expect(screen.getByText(meta.readingTime)).toBeInTheDocument();
});
});
diff --git a/src/components/organisms/layout/summary.tsx b/src/components/organisms/layout/summary.tsx
index 28aac68..8b47833 100644
--- a/src/components/organisms/layout/summary.tsx
+++ b/src/components/organisms/layout/summary.tsx
@@ -5,7 +5,7 @@ import Link from '@components/atoms/links/link';
import ResponsiveImage, {
type ResponsiveImageProps,
} from '@components/molecules/images/responsive-image';
-import Meta, { type MetaItem } from '@components/molecules/layout/meta';
+import Meta, { MetaData } from '@components/molecules/layout/meta';
import { FC, ReactNode } from 'react';
import { useIntl } from 'react-intl';
import styles from './summary.module.scss';
@@ -15,24 +15,15 @@ export type Cover = Pick<
'alt' | 'src' | 'width' | 'height'
>;
-export type RequiredMetaKey = 'publication';
-
-export type RequiredMeta = {
- [key in RequiredMetaKey]: MetaItem;
-};
-
-export type OptionalMetaKey =
+export type SummaryMeta = Pick<
+ MetaData,
| 'author'
- | 'categories'
- | 'comments'
+ | 'commentsCount'
+ | 'publication'
| 'readingTime'
- | 'update';
-
-export type OptionalMeta = {
- [key in OptionalMetaKey]?: MetaItem;
-};
-
-export type Meta = RequiredMeta & OptionalMeta;
+ | 'thematics'
+ | 'update'
+>;
export type SummaryProps = {
/**
@@ -46,7 +37,7 @@ export type SummaryProps = {
/**
* The post meta.
*/
- meta: Meta;
+ meta: SummaryMeta;
/**
* The post title.
*/
@@ -100,7 +91,11 @@ const Summary: FC<SummaryProps> = ({
</Link>
</header>
<div className={styles.body}>
- {excerpt}
+ {typeof excerpt === 'string' ? (
+ <div dangerouslySetInnerHTML={{ __html: excerpt }} />
+ ) : (
+ excerpt
+ )}
<ButtonLink target={url} className={styles['read-more']}>
<>
{readMore}