-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
basic-layout.tsx
27 lines (26 loc) · 891 Bytes
/
basic-layout.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import Head from 'next/head'
import React, { ReactNode, useRef } from 'react'
import { useBlogContext } from './blog-context'
import { HeadingContext } from './mdx-theme'
export const BasicLayout = ({ children }: { children: ReactNode }) => {
const { config, opts } = useBlogContext()
const title = `${opts.title}${config.titleSuffix || ''}`
const ref = useRef<HTMLHeadingElement>(null)
return (
<article
className="nx-container nx-prose-sm nx-prose dark:nx-prose-dark md:nx-prose"
dir="ltr"
>
<Head>
<title>{title}</title>
{config.head?.({ title, meta: opts.frontMatter })}
</Head>
<HeadingContext.Provider value={ref}>
{opts.hasJsxInH1 ? <h1 ref={ref} /> : null}
{!opts.hasJsxInH1 ? <h1>{opts.title}</h1> : null}
{children}
{config.footer}
</HeadingContext.Provider>
</article>
)
}