Skip to content

Commit e7cb4d9

Browse files
committed
feat: update layout navbar
1 parent ab399bb commit e7cb4d9

File tree

8 files changed

+67
-34
lines changed

8 files changed

+67
-34
lines changed

apps/docs/global.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { routing } from '@/i18n/routing';
2+
import type messages from './messages/en.json';
3+
4+
declare module 'next-intl' {
5+
interface AppConfig {
6+
Locale: (typeof routing.locales)[number];
7+
Messages: typeof messages;
8+
}
9+
}

apps/docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"fumadocs-core": "15.2.15",
1717
"fumadocs-mdx": "11.6.2",
1818
"fumadocs-ui": "15.2.15",
19+
"lucide-react": "^0.511.0",
1920
"next": "15.3.1",
2021
"next-intl": "^4.1.0",
2122
"react": "^19.1.0",
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import { baseOptions } from '@/app/[locale]/layout.config';
1+
import { useBaseOptions } from '@/hooks/useLayoutOptions';
22
import { HomeLayout } from 'fumadocs-ui/layouts/home';
3-
import { useTranslations } from 'next-intl';
43
import type { ReactNode } from 'react';
54

65
export default function Layout({ children }: { children: ReactNode }) {
7-
const t = useTranslations('baseOptions');
8-
return (
9-
<HomeLayout {...baseOptions({ title: t('title') })}>{children}</HomeLayout>
10-
);
6+
const baseOptions = useBaseOptions();
7+
return <HomeLayout {...baseOptions}>{children}</HomeLayout>;
118
}

apps/docs/src/app/[locale]/layout.config.tsx

Lines changed: 0 additions & 21 deletions
This file was deleted.

apps/docs/src/app/[locale]/static/[page]/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { routing } from '@/i18n/routing';
22
import { getOramaDocuments } from '@/lib/orama/orama-document';
33
import { sourceMap } from '@/lib/source';
4+
import type { Locale } from 'next-intl';
45

56
import { NextResponse } from 'next/server';
67

78
export const revalidate = false;
89

910
export async function GET(
1011
_req: Request,
11-
{ params }: { params: Promise<{ locale: string; page: string }> },
12+
{ params }: { params: Promise<{ locale: Locale; page: string }> },
1213
) {
1314
const { locale, page = '0' } = await params;
1415
const s = sourceMap[locale];

apps/docs/src/components/layout.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
'use client';
22

3-
import { baseOptions } from '@/app/[locale]/layout.config';
3+
import { useBaseOptions } from '@/hooks/useLayoutOptions';
44
import type { PageTree } from 'fumadocs-core/server';
55
import {
66
type DocsLayoutProps,
77
DocsLayout as FumaDocsLayout,
88
} from 'fumadocs-ui/layouts/docs';
9-
import { useTranslations } from 'next-intl';
109
import type { ReactNode } from 'react';
1110

1211
export function DocsLayout({
1312
children,
1413
pageTree,
15-
}: { children: ReactNode; pageTree: PageTree.Root }) {
16-
const t = useTranslations('baseOptions');
14+
}: {
15+
children: ReactNode;
16+
pageTree: PageTree.Root;
17+
}) {
18+
const baseOptions = useBaseOptions();
1719
const docsLayout: DocsLayoutProps = {
18-
...baseOptions({ title: t('title') }),
20+
...baseOptions,
1921
tree: pageTree,
2022
sidebar: {},
21-
githubUrl: 'https://github.com/xiaoyu2er/nextjs-i18n-docs',
2223
};
2324

2425
return <FumaDocsLayout {...docsLayout}>{children}</FumaDocsLayout>;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
2+
import { Book } from 'lucide-react';
3+
import { useTranslations } from 'next-intl';
4+
5+
export const useBaseOptions = () => {
6+
const t = useTranslations('baseOptions');
7+
return {
8+
nav: {
9+
title: (
10+
<>
11+
<svg
12+
width="24"
13+
height="24"
14+
xmlns="http://www.w3.org/2000/svg"
15+
aria-label="Logo"
16+
>
17+
<title>Logo</title>
18+
<circle cx={12} cy={12} r={12} fill="currentColor" />
19+
</svg>
20+
{t('title')}
21+
</>
22+
),
23+
},
24+
githubUrl: 'https://github.com/xiaoyu2er/nextjs-i18n-docs',
25+
links: [
26+
{
27+
icon: <Book />,
28+
text: t('doc'),
29+
url: '/docs/',
30+
},
31+
],
32+
} as BaseLayoutProps;
33+
};

pnpm-lock.yaml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)