MCPcopy
hub / github.com/github/docs / DefaultLayout

Function DefaultLayout

components/DefaultLayout.tsx:18–138  ·  view source on GitHub ↗
(props: Props)

Source from the content-addressed store, hash-verified

16
17type Props = { children?: React.ReactNode }
18export const DefaultLayout = (props: Props) => {
19 const {
20 page,
21 error,
22 isHomepageVersion,
23 currentPathWithoutLanguage,
24 currentVersion,
25 currentProduct,
26 relativePath,
27 fullUrl,
28 status,
29 } = useMainContext()
30 const { t } = useTranslation(['errors', 'meta', 'scroll_button'])
31 const router = useRouter()
32 const metaDescription = page.introPlainText ? page.introPlainText : t('default_description')
33
34 // This is only true when we do search indexing which renders every page
35 // just to be able to `cheerio` load the main body (and the meta
36 // keywords tag).
37 if (MINIMAL_RENDER) {
38 return (
39 <div>
40 <Head>
41 <title>{page.fullTitle}</title>
42 </Head>
43
44 {/* For local site search indexing */}
45 <div className="d-none d-xl-block" data-search="breadcrumbs">
46 <Breadcrumbs />
47 </div>
48
49 <main id="main-content" style={{ scrollMarginTop: '5rem' }}>
50 {props.children}
51 </main>
52 </div>
53 )
54 }
55
56 return (
57 <>
58 <Head>
59 {error === '404' ? (
60 <title>{t('oops')}</title>
61 ) : (!isHomepageVersion && page.fullTitle) ||
62 (currentPathWithoutLanguage.includes('enterprise-server') && page.fullTitle) ? (
63 <title>{page.fullTitle}</title>
64 ) : null}
65
66 {/* For Google and Bots */}
67 <meta name="description" content={metaDescription} />
68 {page.hidden && <meta name="robots" content="noindex" />}
69 {page.languageVariants.map((languageVariant) => {
70 return (
71 <link
72 key={languageVariant.href}
73 rel="alternate"
74 hrefLang={languageVariant.hreflang}
75 href={`https://docs.github.com${languageVariant.href}`}

Callers

nothing calls this directly

Calls 2

useMainContextFunction · 0.90
useTranslationFunction · 0.90

Tested by

no test coverage detected