forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefaultLayout.tsx
More file actions
57 lines (48 loc) · 1.74 KB
/
DefaultLayout.tsx
File metadata and controls
57 lines (48 loc) · 1.74 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import Head from 'next/head'
import { SidebarNav } from 'components/SidebarNav'
import { Header } from 'components/Header'
import { SmallFooter } from 'components/SmallFooter'
import { ScrollButton } from 'components/ScrollButton'
import { SupportSection } from 'components/SupportSection'
import { DeprecationBanner } from 'components/DeprecationBanner'
import { useMainContext } from 'components/context/MainContext'
import { useTranslation } from './hooks/useTranslation'
type Props = { children?: React.ReactNode }
export const DefaultLayout = (props: Props) => {
const { page, error, isHomepageVersion } = useMainContext()
const { t } = useTranslation('errors')
return (
<div className="d-lg-flex">
<Head>
{error === '404' ? (
<title>{t('oops')}</title>
) : !isHomepageVersion && page.fullTitle ? (
<title>{page.fullTitle}</title>
) : null}
{/* For Google and Bots */}
{page.introPlainText && <meta name="description" content={page.introPlainText} />}
{page.topics.length > 0 && <meta name="keywords" content={page.topics.join(',')} />}
{page.hidden && <meta name="robots" content="noindex" />}
{page.languageVariants.map((languageVariant) => {
return (
<link
key={languageVariant.href}
rel="alternate"
hrefLang={languageVariant.hreflang}
href={`https://docs.github.com${languageVariant.href}`}
/>
)
})}
</Head>
<SidebarNav />
<main className="flex-1 min-width-0">
<Header />
<DeprecationBanner />
{props.children}
<SupportSection />
<SmallFooter />
<ScrollButton />
</main>
</div>
)
}