aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/blog
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-11-20 11:02:20 +0100
committerArmand Philippot <git@armandphilippot.com>2023-11-20 19:20:21 +0100
commitd5ade2359539648845a5854ed353b29367961d74 (patch)
tree45a49d90090408887135a971a7fd79c45d9dcd94 /src/pages/blog
parent6ab9635a22d69186c8a24181ad5df7736e288577 (diff)
refactor(components): extract MetaItem from MetaList
* replace `items` prop on MetaList with `children` prop: it was too restrictive and the global options was not really useful. It is better too give control to the consumers.
Diffstat (limited to 'src/pages/blog')
-rw-r--r--src/pages/blog/index.tsx47
-rw-r--r--src/pages/blog/page/[number].tsx47
2 files changed, 46 insertions, 48 deletions
diff --git a/src/pages/blog/index.tsx b/src/pages/blog/index.tsx
index 5a13e3e..6ed6eda 100644
--- a/src/pages/blog/index.tsx
+++ b/src/pages/blog/index.tsx
@@ -9,13 +9,14 @@ import {
getLayout,
Heading,
LinksWidget,
- type MetaItemData,
Notice,
PageLayout,
PostsList,
Pagination,
type RenderPaginationLink,
type RenderPaginationItemAriaLabel,
+ MetaList,
+ MetaItem,
} from '../../components';
import {
getArticles,
@@ -183,28 +184,6 @@ const BlogPage: NextPageWithLayout<BlogPageProps> = ({
[intl]
);
- const headerMeta: MetaItemData[] = totalArticles
- ? [
- {
- id: 'posts-count',
- label: intl.formatMessage({
- defaultMessage: 'Total:',
- description: 'Page: total label',
- id: 'kNBXyK',
- }),
- value: intl.formatMessage(
- {
- defaultMessage:
- '{postsCount, plural, =0 {No articles} one {# article} other {# articles}}',
- description: 'Page: posts count meta',
- id: 'RvGb2c',
- },
- { postsCount: totalArticles }
- ),
- },
- ]
- : [];
-
const paginationAriaLabel = intl.formatMessage({
defaultMessage: 'Pagination',
description: 'BlogPage: pagination accessible name',
@@ -234,7 +213,27 @@ const BlogPage: NextPageWithLayout<BlogPageProps> = ({
title={title}
breadcrumb={breadcrumbItems}
breadcrumbSchema={breadcrumbSchema}
- headerMeta={headerMeta}
+ headerMeta={
+ <MetaList>
+ <MetaItem
+ isInline
+ label={intl.formatMessage({
+ defaultMessage: 'Total:',
+ description: 'Page: total label',
+ id: 'kNBXyK',
+ })}
+ value={intl.formatMessage(
+ {
+ defaultMessage:
+ '{postsCount, plural, =0 {No articles} one {# article} other {# articles}}',
+ description: 'Page: posts count meta',
+ id: 'RvGb2c',
+ },
+ { postsCount: totalArticles }
+ )}
+ />
+ </MetaList>
+ }
widgets={[
<LinksWidget
heading={
diff --git a/src/pages/blog/page/[number].tsx b/src/pages/blog/page/[number].tsx
index 03b641b..27d1816 100644
--- a/src/pages/blog/page/[number].tsx
+++ b/src/pages/blog/page/[number].tsx
@@ -10,12 +10,13 @@ import {
getLayout,
Heading,
LinksWidget,
- type MetaItemData,
PageLayout,
PostsList,
Pagination,
type RenderPaginationLink,
type RenderPaginationItemAriaLabel,
+ MetaList,
+ MetaItem,
} from '../../../components';
import {
getArticles,
@@ -187,28 +188,6 @@ const BlogPage: NextPageWithLayout<BlogPageProps> = ({
[intl]
);
- const headerMeta: MetaItemData[] = totalArticles
- ? [
- {
- id: 'posts-count',
- label: intl.formatMessage({
- defaultMessage: 'Total:',
- description: 'Page: total label',
- id: 'kNBXyK',
- }),
- value: intl.formatMessage(
- {
- defaultMessage:
- '{postsCount, plural, =0 {No articles} one {# article} other {# articles}}',
- description: 'Page: posts count meta',
- id: 'RvGb2c',
- },
- { postsCount: totalArticles }
- ),
- },
- ]
- : [];
-
const paginationAriaLabel = intl.formatMessage({
defaultMessage: 'Pagination',
description: 'BlogPage: pagination accessible name',
@@ -238,7 +217,27 @@ const BlogPage: NextPageWithLayout<BlogPageProps> = ({
title={pageTitleWithPageNumber}
breadcrumb={breadcrumbItems}
breadcrumbSchema={breadcrumbSchema}
- headerMeta={headerMeta}
+ headerMeta={
+ <MetaList>
+ <MetaItem
+ isInline
+ label={intl.formatMessage({
+ defaultMessage: 'Total:',
+ description: 'Page: total label',
+ id: 'kNBXyK',
+ })}
+ value={intl.formatMessage(
+ {
+ defaultMessage:
+ '{postsCount, plural, =0 {No articles} one {# article} other {# articles}}',
+ description: 'Page: posts count meta',
+ id: 'RvGb2c',
+ },
+ { postsCount: totalArticles }
+ )}
+ />
+ </MetaList>
+ }
widgets={[
<LinksWidget
heading={