Skip to content

Commit f851bd9

Browse files
committed
refactor to use global config.ts for names and links
1 parent d2f8da2 commit f851bd9

7 files changed

Lines changed: 26 additions & 9 deletions

File tree

app/api/chat/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createOpenRouter } from '@openrouter/ai-sdk-provider';
22
import { streamText, tool, type UIMessage } from 'ai';
33
import { z } from 'zod';
44
import { liteClient } from 'algoliasearch/lite';
5+
import { siteConfig } from '@/lib/config';
56

67
const algolia = liteClient(
78
process.env.NEXT_PUBLIC_ALGOLIA_APP_ID!,
@@ -72,7 +73,7 @@ const openrouter = createOpenRouter({
7273
});
7374

7475
const systemPrompt = [
75-
'You are a helpful technical assistant for Next Commerce developer documentation.',
76+
`You are a helpful technical assistant for ${siteConfig.companyName} developer documentation.`,
7677
'Your job is to answer developer questions clearly and concisely based on the documentation provided in context.',
7778
'Base your answers on the documentation context below. Cite sources as markdown links using the document URL.',
7879
'When writing code examples, use the language shown in the documentation.',

app/docs/[[...slug]]/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { getMDXComponents } from '@/components/mdx';
1111
import { createRelativeLink } from 'fumadocs-ui/mdx';
1212
import { VersionSelector } from '@/components/version-selector';
1313
import { AutoExpandBody } from '@/components/auto-expand-body';
14+
import { siteConfig } from '@/lib/config';
1415
import type { Metadata } from 'next';
1516

1617
export default async function Page(props: {
@@ -30,7 +31,7 @@ export default async function Page(props: {
3031
<ViewOptionsPopover
3132
className="flex items-center gap-2 rounded-lg p-2 border bg-fd-secondary/50 text-sm text-fd-secondary-foreground transition-colors hover:bg-fd-accent h-auto"
3233
markdownUrl={`/docs-raw/${(params.slug ?? []).join('/')}`}
33-
githubUrl={`https://github.com/29next/developer-docs/blob/main/content/docs/${page.path}`}
34+
githubUrl={`${siteConfig.githubContentUrl}/${page.path}`}
3435
/>
3536
<VersionSelector />
3637
</div>

app/layout.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import { RootProvider } from 'fumadocs-ui/provider/next';
22
import { AlgoliaDialog } from '@/components/search';
33
import { AISearch, AISearchPanel, AISearchTrigger } from '@/components/ai/search';
44
import { MessageCircleIcon } from 'lucide-react';
5+
import { siteConfig } from '@/lib/config';
56
import type { Metadata } from 'next';
67
import type { ReactNode } from 'react';
78
import './globals.css';
89

910
export const metadata: Metadata = {
1011
title: {
11-
template: '%s | Developers | Next Commerce',
12-
default: 'Developers | Next Commerce',
12+
template: `%s | Developers | ${siteConfig.companyName}`,
13+
default: `Developers | ${siteConfig.companyName}`,
1314
},
1415
};
1516

components/ai/search.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,11 @@ function Input(props: ComponentProps<'textarea'>) {
232232
);
233233
}
234234

235+
import { siteConfig } from '@/lib/config';
236+
235237
const roleName: Record<string, string> = {
236238
user: 'you',
237-
assistant: 'Next Commerce AI',
239+
assistant: `${siteConfig.companyName} AI`,
238240
};
239241

240242
function Message({ message, ...props }: { message: UIMessage } & ComponentProps<'div'>) {

lib/config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export const siteConfig = {
2+
companyName: 'Next Commerce',
3+
githubOrg: 'NextCommerceCo',
4+
githubRepo: 'developer-docs',
5+
get githubUrl() {
6+
return `https://github.com/${this.githubOrg}/${this.githubRepo}`;
7+
},
8+
get githubContentUrl() {
9+
return `${this.githubUrl}/blob/main/content/docs`;
10+
},
11+
};

lib/layout.shared.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
22
import Image from 'next/image';
3+
import { siteConfig } from '@/lib/config';
34

45
export function baseOptions(): BaseLayoutProps {
56
return {
67
nav: {
78
title: (
89
<>
9-
<Image src="/logo-light.png" alt="Next Commerce" width={105} height={21} className="dark:hidden" />
10-
<Image src="/logo-dark.png" alt="Next Commerce" width={105} height={21} className="hidden dark:block" />
10+
<Image src="/logo-light.png" alt={siteConfig.companyName} width={105} height={21} className="dark:hidden" />
11+
<Image src="/logo-dark.png" alt={siteConfig.companyName} width={105} height={21} className="hidden dark:block" />
1112
</>
1213
),
1314
},
14-
githubUrl: 'https://github.com/NextCommerceCo/developer-docs',
15+
githubUrl: siteConfig.githubUrl,
1516
};
1617
}

next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
import "./.next/dev/types/routes.d.ts";
3+
import "./.next/types/routes.d.ts";
44

55
// NOTE: This file should not be edited
66
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

0 commit comments

Comments
 (0)