From 4be9c3d80c81f5b0063d49edb9bcea88ad7662e5 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Thu, 16 Dec 2021 12:40:23 -0600 Subject: [PATCH] SEO component --- web/components/SEO.tsx | 40 +++++++++++++++++++++++++++ web/pages/[username]/[contractId].tsx | 31 ++++++--------------- web/pages/_app.tsx | 4 ++- 3 files changed, 52 insertions(+), 23 deletions(-) create mode 100644 web/components/SEO.tsx diff --git a/web/components/SEO.tsx b/web/components/SEO.tsx new file mode 100644 index 00000000..6e4b76b6 --- /dev/null +++ b/web/components/SEO.tsx @@ -0,0 +1,40 @@ +import Head from 'next/head' + +export function SEO(props: { + title: string + description: string + url?: string + children?: any[] +}) { + const { title, description, url, children } = props + + return ( + + {title} | Mantic Markets + + + + + + {url && ( + + )} + + {children} + + ) +} diff --git a/web/pages/[username]/[contractId].tsx b/web/pages/[username]/[contractId].tsx index 7a317ea5..c97b1482 100644 --- a/web/pages/[username]/[contractId].tsx +++ b/web/pages/[username]/[contractId].tsx @@ -1,5 +1,4 @@ import React from 'react' -import Head from 'next/head' import clsx from 'clsx' import { useContractWithPreload } from '../../hooks/use-contract' @@ -15,13 +14,15 @@ import { Title } from '../../components/title' import { Spacer } from '../../components/layout/spacer' import { User } from '../../lib/firebase/users' import { Contract, getContract } from '../../lib/firebase/contracts' +import { SEO } from '../../components/SEO' export async function getStaticProps(props: { params: any }) { - const { contractId } = props.params + const { username, contractId } = props.params const contract = (await getContract(contractId)) || null return { props: { + username, contractId, contract, }, @@ -37,6 +38,7 @@ export async function getStaticPaths() { export default function ContractPage(props: { contract: Contract | null contractId: string + username: string }) { const user = useUser() @@ -51,26 +53,11 @@ export default function ContractPage(props: { return ( - - {contract.question} | Mantic Markets - - - - +
diff --git a/web/pages/_app.tsx b/web/pages/_app.tsx index 8d121566..1448a27e 100644 --- a/web/pages/_app.tsx +++ b/web/pages/_app.tsx @@ -17,13 +17,15 @@ function MyApp({ Component, pageProps }: AppProps) { - +