Skip to content

Commit 01f5c62

Browse files
committed
refactor: adjust layout code structure
1 parent d01c667 commit 01f5c62

File tree

2 files changed

+39
-40
lines changed

2 files changed

+39
-40
lines changed

app/[lang]/layout.jsx

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Footer, Layout, Navbar, LastUpdated } from 'nextra-theme-docs'
22
import { TitleFullWithLogo } from '../components/logo-title'
3-
import { Search } from 'nextra/components'
3+
import { Head, Search } from 'nextra/components'
44
import { getPageMap } from 'nextra/page-map'
55
import { localeResources } from '../../locales'
66
import 'nextra-theme-docs/style.css'
7-
7+
88
export const metadata = {
99
applicationName: 'SJMCL',
1010
appleWebApp: {
@@ -19,7 +19,7 @@ export const metadata = {
1919
template: '%s | SJMCL'
2020
},
2121
}
22-
22+
2323
export default async function RootLayout({ children, params }) {
2424
const { lang } = await params
2525
let pageMap = await getPageMap(`/${lang}`)
@@ -38,31 +38,47 @@ export default async function RootLayout({ children, params }) {
3838
placeholder={t.search.placeholder}
3939
/>
4040
)
41-
41+
4242
const footer = (
4343
<Footer>
4444
沪 ICP 备 05052060 号-7
45-
<br />
45+
<br/>
4646
{new Date().getFullYear()} © {t.footer.copyright}
4747
</Footer>
4848
)
4949

5050
return (
51-
<Layout
52-
// banner={banner}
53-
navbar={navbar}
54-
search={search}
55-
pageMap={pageMap}
56-
docsRepositoryBase="https://github.com/UNIkeEN/SJMCL/tree/main"
57-
footer={footer}
58-
editLink={t.editLink}
59-
feedback={{ content: t.feedbackLink }}
60-
lastUpdated={<LastUpdated>{t.lastUpdated}</LastUpdated>}
61-
i18n={Object.entries(localeResources).map(([locale, value]) => ({
62-
locale, name: value.display_name,
63-
}))}
51+
<html
52+
// Not required, but good for SEO
53+
lang="en"
54+
// Required to be set
55+
dir="ltr"
56+
// Suggested by `next-themes` package https://github.com/pacocoursey/next-themes#with-app
57+
suppressHydrationWarning
6458
>
65-
{children}
66-
</Layout>
59+
<Head
60+
// ... Your additional head options
61+
>
62+
{/* Your additional tags should be passed as `children` of `<Head>` element */}
63+
</Head>
64+
<body>
65+
<Layout
66+
// banner={banner}
67+
navbar={navbar}
68+
search={search}
69+
pageMap={pageMap}
70+
docsRepositoryBase="https://github.com/UNIkeEN/SJMCL/tree/main"
71+
footer={footer}
72+
editLink={t.editLink}
73+
feedback={{content: t.feedbackLink}}
74+
lastUpdated={<LastUpdated>{t.lastUpdated}</LastUpdated>}
75+
i18n={Object.entries(localeResources).map(([locale, value]) => ({
76+
locale, name: value.display_name,
77+
}))}
78+
>
79+
{children}
80+
</Layout>
81+
</body>
82+
</html>
6783
)
6884
}

app/layout.jsx

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,10 @@
11
import { ColorModeSyncWrapper } from './components/color-mode-wrapper'
2-
import { Head } from 'nextra/components'
32
import './styles/global.css'
43

54
export default function RootLayout({ children }) {
65
return (
7-
<html
8-
// Not required, but good for SEO
9-
lang="en"
10-
// Required to be set
11-
dir="ltr"
12-
// Suggested by `next-themes` package https://github.com/pacocoursey/next-themes#with-app
13-
suppressHydrationWarning
14-
>
15-
<Head
16-
// ... Your additional head options
17-
>
18-
{/* Your additional tags should be passed as `children` of `<Head>` element */}
19-
</Head>
20-
<body>
21-
<ColorModeSyncWrapper>
22-
{children}
23-
</ColorModeSyncWrapper>
24-
</body>
25-
</html>
6+
<ColorModeSyncWrapper>
7+
{children}
8+
</ColorModeSyncWrapper>
269
)
2710
}

0 commit comments

Comments
 (0)