Skip to content
Snippets Groups Projects
Commit 5e0564a6 authored by Tarje Lavik's avatar Tarje Lavik
Browse files

Add meta title

parent 2936274f
No related branches found
No related tags found
No related merge requests found
import Head from 'next/head'
import { usePreviewSubscription } from '../lib/sanity'
import { routeQuery } from '../lib/queries/routeQuery'
import { getClient } from '../lib/sanity.server'
import { getRoutes } from '../lib/api' import { getRoutes } from '../lib/api'
import { Box, Container, Text } from '@chakra-ui/react' import { Box, Container, Text } from '@chakra-ui/react'
import Date from '../components/Date' import Date from '../components/Date'
...@@ -6,9 +10,6 @@ import Sections from '../components/Sections/Sections' ...@@ -6,9 +10,6 @@ import Sections from '../components/Sections/Sections'
import PortableTextBlock from '../components/PT/PortableTextBlock' import PortableTextBlock from '../components/PT/PortableTextBlock'
import TableOfContent from '../components/Layout/TableOfContent' import TableOfContent from '../components/Layout/TableOfContent'
import Footnotes from '../components/Layout/Footnotes' import Footnotes from '../components/Layout/Footnotes'
import { usePreviewSubscription } from '../lib/sanity'
import { routeQuery } from '../lib/queries/routeQuery'
import { getClient } from '../lib/sanity.server'
/** /**
* Helper function to return the correct version of the document * Helper function to return the correct version of the document
...@@ -42,10 +43,14 @@ export default function Page({ data, preview }) { ...@@ -42,10 +43,14 @@ export default function Page({ data, preview }) {
// It'll be completely blank when they start! // It'll be completely blank when they start!
return ( return (
<Layout preview={preview} site={page?.siteSettings}> <Layout preview={preview} site={page?.siteSettings}>
{/* <pre>{JSON.stringify(previewData, null, 2)}</pre> */} {/* <pre>{JSON.stringify(page, null, 2)}</pre> */}
<Head>
<title>{page.route[0].page.label + ' - ' + page.siteSettings.title}</title>
</Head>
<Container maxWidth="full" centerContent> <Container maxWidth="full" centerContent>
{/* A Page */} {/* A Page */}
{page?.route?.page?.content && <Sections sections={page.route.page.content} />} {page?.route[0]?.page?.content && <Sections sections={page.route[0].page.content} />}
{/* If LinguisticDocument the content is in the body field */} {/* If LinguisticDocument the content is in the body field */}
{page?.route[0]?.page?.body && <PortableTextBlock blocks={page.route[0].page.body} />} {page?.route[0]?.page?.body && <PortableTextBlock blocks={page.route[0].page.body} />}
...@@ -53,9 +58,9 @@ export default function Page({ data, preview }) { ...@@ -53,9 +58,9 @@ export default function Page({ data, preview }) {
{page?.route[0]?.page?.body && <Footnotes blocks={page.route[0].page.body} />} {page?.route[0]?.page?.body && <Footnotes blocks={page.route[0].page.body} />}
{/* Add TOC */} {/* Add TOC */}
{page?.route?.page?.body && ( {page?.route[0]?.page?.body && (
<Box position="fixed" left="10" top="50vh" display={{ base: 'none', md: 'inherit' }}> <Box position="fixed" left="10" top="50vh" display={{ base: 'none', md: 'inherit' }}>
<TableOfContent blocks={page?.route.page.body} /> <TableOfContent blocks={page?.route[0].page.body} />
</Box> </Box>
)} )}
......
import Head from 'next/head'
import { getFrontpage } from '../lib/api' import { getFrontpage } from '../lib/api'
import Layout from '../components/Layout' import Layout from '../components/Layout'
import RenderSections from '../components/Sections/RenderSection' import RenderSections from '../components/Sections/RenderSection'
...@@ -6,6 +7,7 @@ import { Container } from '@chakra-ui/react' ...@@ -6,6 +7,7 @@ import { Container } from '@chakra-ui/react'
export default function Index({ data, preview }) { export default function Index({ data, preview }) {
return ( return (
<Layout preview={preview} site={data.siteSettings}> <Layout preview={preview} site={data.siteSettings}>
<Head>{data?.siteSettings?.title && <title>{data.siteSettings.title}</title>}</Head>
<Container maxW="full"> <Container maxW="full">
{data.frontpage.content && <RenderSections sections={data.frontpage.content} />} {data.frontpage.content && <RenderSections sections={data.frontpage.content} />}
</Container> </Container>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment