From 5b19a6a359887515bf65b5a79b7a2795cf972f45 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Tue, 18 Feb 2020 14:31:27 +0300 Subject: [PATCH] Copyright component extraction --- pages/_error.tsx | 3 ++- src/components/Copyright/index.tsx | 10 ++++++++++ src/components/Footer/index.tsx | 12 ++---------- src/config.ts | 4 ++++ 4 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 src/components/Copyright/index.tsx diff --git a/pages/_error.tsx b/pages/_error.tsx index c541d7ca..dff192bb 100644 --- a/pages/_error.tsx +++ b/pages/_error.tsx @@ -1,6 +1,7 @@ import { NextPage } from 'next' import { Wrapper } from 'src/components/Wrapper' import { NotFound } from 'src/components/NotFound' +import { Copyright } from 'src/components/Copyright' const Page: NextPage = () => ( ( footer={(
- © 2012—2019 Шлиссельбургская детская художественная школа +
)} diff --git a/src/components/Copyright/index.tsx b/src/components/Copyright/index.tsx new file mode 100644 index 00000000..a5e523ed --- /dev/null +++ b/src/components/Copyright/index.tsx @@ -0,0 +1,10 @@ +import { useContext } from 'react' +import { ConfigContext } from 'src/context/ConfigContext' + +export const Copyright: React.FC = () => { + const { yearStart, yearEnd } = useContext(ConfigContext) + + return ( + © {yearStart}—{yearEnd} Шлиссельбургская детская художественная школа + ) +} diff --git a/src/components/Footer/index.tsx b/src/components/Footer/index.tsx index a3e69d0a..f8fbe559 100644 --- a/src/components/Footer/index.tsx +++ b/src/components/Footer/index.tsx @@ -1,7 +1,6 @@ -import * as React from 'react' +import { Copyright } from '../Copyright' const mailto = email => `mailto:${email}` -const currentYear = () => (new Date()).getFullYear() export interface IFooterProps { address: string @@ -24,10 +23,7 @@ export const Footer: React.FC = props => (
- + {!props.showAuthor ? null : ( )} @@ -43,7 +39,3 @@ const Author = () => ( ) - -const Copyright = ({ yearStart, yearEnd }) => ( - © {yearStart}—{yearEnd} Шлиссельбургская детская художественная школа -) diff --git a/src/config.ts b/src/config.ts index 7e9d4a15..c3b3c1f2 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,5 +1,9 @@ +const currentYear = () => (new Date()).getFullYear() + export default { address: "г. Шлиссельбург ул. 18 января д. 3", telephone: "+7 (81362) 76-312", email: "hudozka@gmail.com", + yearStart: 2012, + yearEnd: currentYear(), }