From 732d0943f8041d76262222a092b014f2557085ef Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 2 May 2022 18:57:29 +0200 Subject: chore: add homepage --- src/components/templates/layout/layout.tsx | 107 ++++++++++++++++++++++++----- 1 file changed, 88 insertions(+), 19 deletions(-) (limited to 'src/components/templates/layout/layout.tsx') diff --git a/src/components/templates/layout/layout.tsx b/src/components/templates/layout/layout.tsx index 601ced4..e1be1af 100644 --- a/src/components/templates/layout/layout.tsx +++ b/src/components/templates/layout/layout.tsx @@ -1,4 +1,3 @@ -import photo from '@assets/images/armand-philippot.jpg'; import ButtonLink from '@components/atoms/buttons/button-link'; import Career from '@components/atoms/icons/career'; import CCBySA from '@components/atoms/icons/cc-by-sa'; @@ -8,13 +7,19 @@ import Home from '@components/atoms/icons/home'; import PostsStack from '@components/atoms/icons/posts-stack'; import Main from '@components/atoms/layout/main'; import NoScript from '@components/atoms/layout/no-script'; -import Footer from '@components/organisms/layout/footer'; -import Header, { HeaderProps } from '@components/organisms/layout/header'; -import { settings } from '@utils/config'; +import Footer, { FooterProps } from '@components/organisms/layout/footer'; +import Header, { type HeaderProps } from '@components/organisms/layout/header'; +import useSettings from '@utils/hooks/use-settings'; +import Script from 'next/script'; import { FC, ReactNode } from 'react'; import { useIntl } from 'react-intl'; +import { Person, SearchAction, WebSite, WithContext } from 'schema-dts'; import styles from './layout.module.scss'; +export type QueryAction = SearchAction & { + 'query-input': string; +}; + export type LayoutProps = Pick & { /** * The layout main content. @@ -33,6 +38,9 @@ export type LayoutProps = Pick & { */ const Layout: FC = ({ children, isHome, ...props }) => { const intl = useIntl(); + const { website } = useSettings(); + const { baseline, copyright, locales, name, picture, url } = website; + const skipToContent = intl.formatMessage({ defaultMessage: 'Skip to content', description: 'Layout: Skip to content link', @@ -45,12 +53,12 @@ const Layout: FC = ({ children, isHome, ...props }) => { id: '7jVUT6', }); - const copyright = { + const copyrightData = { dates: { - start: settings.copyright.startYear, - end: settings.copyright.endYear, + start: copyright.start, + end: copyright.end, }, - owner: settings.name, + owner: name, icon: , }; @@ -80,21 +88,77 @@ const Layout: FC = ({ children, isHome, ...props }) => { id: 'AE4kCD', }); - const nav: HeaderProps['nav'] = [ - { id: 'home', label: homeLabel, href: '#', logo: }, - { id: 'blog', label: blogLabel, href: '#', logo: }, + const mainNav: HeaderProps['nav'] = [ + { id: 'home', label: homeLabel, href: '/', logo: }, + { id: 'blog', label: blogLabel, href: '/blog', logo: }, { id: 'projects', label: projectsLabel, - href: '#', + href: '/projets', logo: , }, - { id: 'cv', label: cvLabel, href: '#', logo: }, - { id: 'contact', label: contactLabel, href: '#', logo: }, + { id: 'cv', label: cvLabel, href: '/cv', logo: }, + { id: 'contact', label: contactLabel, href: '/contact', logo: }, + ]; + + const legalNoticeLabel = intl.formatMessage({ + defaultMessage: 'Legal notice', + description: 'Layout: Legal notice label', + id: 'nwbzKm', + }); + + const footerNav: FooterProps['navItems'] = [ + { id: 'legal-notice', label: legalNoticeLabel, href: '/mentions-legales' }, ]; + const searchActionSchema: QueryAction = { + '@type': 'SearchAction', + target: { + '@type': 'EntryPoint', + urlTemplate: `${url}/recherche?s={search_term_string}`, + }, + query: 'required', + 'query-input': 'required name=search_term_string', + }; + + const schemaJsonLd: WithContext = { + '@context': 'https://schema.org', + '@id': `${url}`, + '@type': 'WebSite', + name: name, + description: baseline, + url: url, + author: { '@id': `${url}/#branding` }, + copyrightYear: Number(copyright.start), + creator: { '@id': `${url}/#branding` }, + editor: { '@id': `${url}/#branding` }, + inLanguage: locales.default, + potentialAction: searchActionSchema, + }; + + const brandingSchema: WithContext = { + '@context': 'https://schema.org', + '@type': 'Person', + '@id': `${url}/#branding`, + name: name, + url: url, + jobTitle: baseline, + image: picture.src, + subjectOf: { '@id': `${url}` }, + }; + return ( <> + +