aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/mentions-legales.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-05-09 18:19:38 +0200
committerArmand Philippot <git@armandphilippot.com>2022-05-09 19:41:02 +0200
commit0d59a6d2995b4119865271ed1908ede0bb96497c (patch)
tree67688e41b7aa253aa58cc08aa360431b07382f9d /src/pages/mentions-legales.tsx
parent339c6957fe92c4ec1809159f09c55201d3794c18 (diff)
refactor: rewrite DescriptionList and Meta components
The meta can have different layout. The previous implementation was not enough to easily change the layout. Also, I prefer to restrict the meta types and it prevents me to repeat myself for the labels.
Diffstat (limited to 'src/pages/mentions-legales.tsx')
-rw-r--r--src/pages/mentions-legales.tsx26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/pages/mentions-legales.tsx b/src/pages/mentions-legales.tsx
index 8dd0a1d..9235e69 100644
--- a/src/pages/mentions-legales.tsx
+++ b/src/pages/mentions-legales.tsx
@@ -5,7 +5,6 @@ import PageLayout, {
type PageLayoutProps,
} from '@components/templates/page/page-layout';
import LegalNoticeContent, { meta } from '@content/pages/legal-notice.mdx';
-import { getFormattedDate } from '@utils/helpers/dates';
import { loadTranslation } from '@utils/helpers/i18n';
import useSettings from '@utils/hooks/use-settings';
import { NestedMDXComponents } from 'mdx/types';
@@ -32,24 +31,15 @@ const LegalNoticePage: NextPage = () => {
{ id: 'legal-notice', name: title, url: '/mentions-legales' },
];
- const publicationLabel = intl.formatMessage({
- defaultMessage: 'Published on:',
- description: 'Meta: publication date label',
- id: 'QGi5uD',
- });
-
- const updateLabel = intl.formatMessage({
- defaultMessage: 'Updated on:',
- description: 'Meta: update date label',
- id: 'tLC7bh',
- });
-
const headerMeta: PageLayoutProps['headerMeta'] = {
publication: {
- name: publicationLabel,
- value: getFormattedDate(dates.publication),
+ date: dates.publication,
},
- update: { name: updateLabel, value: getFormattedDate(dates.update) },
+ update: dates.update
+ ? {
+ date: dates.update,
+ }
+ : undefined,
};
const components: NestedMDXComponents = {
@@ -61,7 +51,7 @@ const LegalNoticePage: NextPage = () => {
const { asPath } = useRouter();
const pageUrl = `${website.url}${asPath}`;
const pagePublicationDate = new Date(dates.publication);
- const pageUpdateDate = new Date(dates.update);
+ const pageUpdateDate = dates.update ? new Date(dates.update) : undefined;
const webpageSchema: WebPage = {
'@id': `${pageUrl}`,
@@ -87,7 +77,7 @@ const LegalNoticePage: NextPage = () => {
copyrightYear: pagePublicationDate.getFullYear(),
creator: { '@id': `${website.url}/#branding` },
dateCreated: pagePublicationDate.toISOString(),
- dateModified: pageUpdateDate.toISOString(),
+ dateModified: pageUpdateDate && pageUpdateDate.toISOString(),
datePublished: pagePublicationDate.toISOString(),
editor: { '@id': `${website.url}/#branding` },
headline: title,