mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-03 15:11:30 +00:00
Adds a floating "Ask the docs" bubble to every docs page. docsgpt-react was already a dependency but nothing imported it, so no widget rendered. The widget reads window and navigator on mount, so it is lazy-loaded with ssr: false from a client wrapper. Its light/dark theme follows the site toggle via next-themes, promoted here from a transitive dependency to a declared one. The key comes from NEXT_PUBLIC_DOCSGPT_API_KEY and the host from NEXT_PUBLIC_DOCSGPT_API_HOST. With no key set the wrapper renders nothing rather than falling through to the demo key the package defaults to. Bumping docsgpt-react to ^0.7.0 also drops a duplicate React. The old ^0.6.3 pin depended on React 18 and npm installed a nested 18.3.1 beside the app's 19.2.8, which would have thrown an invalid hook call on first render.
89 lines
2.6 KiB
React
89 lines
2.6 KiB
React
import Image from 'next/image';
|
|
import { Analytics } from '@vercel/analytics/react';
|
|
import { Banner, Head } from 'nextra/components';
|
|
import { getPageMap } from 'nextra/page-map';
|
|
import { Footer, Layout, Navbar } from 'nextra-theme-docs';
|
|
import 'nextra-theme-docs/style.css';
|
|
|
|
import { DocsGPTChatWidget } from '../components/DocsGPTChatWidget';
|
|
import CuteLogo from '../public/cute-docsgpt.png';
|
|
import themeConfig from '../theme.config';
|
|
|
|
const github = 'https://github.com/arc53/DocsGPT';
|
|
|
|
export const metadata = {
|
|
title: {
|
|
default: 'DocsGPT Documentation',
|
|
template: '%s - DocsGPT Documentation',
|
|
},
|
|
description:
|
|
'Use DocsGPT to chat with your data. DocsGPT is a GPT-powered chatbot that can answer questions about your data.',
|
|
};
|
|
|
|
const navbar = (
|
|
<Navbar
|
|
logo={
|
|
<div style={{ alignItems: 'center', display: 'flex', gap: '8px' }}>
|
|
<Image src={CuteLogo} alt="DocsGPT logo" width={28} height={28} />
|
|
<span style={{ fontWeight: 'bold', fontSize: 18 }}>DocsGPT Docs</span>
|
|
</div>
|
|
}
|
|
projectLink={github}
|
|
chatLink="https://discord.com/invite/n5BX8dh8rU"
|
|
/>
|
|
);
|
|
|
|
const footer = (
|
|
<Footer>
|
|
<span>MIT {new Date().getFullYear()} © </span>
|
|
<a href="https://www.docsgpt.cloud/" target="_blank" rel="noreferrer">
|
|
DocsGPT
|
|
</a>
|
|
{' | '}
|
|
<a href="https://github.com/arc53/DocsGPT" target="_blank" rel="noreferrer">
|
|
GitHub
|
|
</a>
|
|
{' | '}
|
|
<a href="https://blog.docsgpt.cloud/" target="_blank" rel="noreferrer">
|
|
Blog
|
|
</a>
|
|
</Footer>
|
|
);
|
|
|
|
export default async function RootLayout({ children }) {
|
|
return (
|
|
<html lang="en" dir="ltr" suppressHydrationWarning>
|
|
<Head>
|
|
<link
|
|
rel="apple-touch-icon"
|
|
sizes="180x180"
|
|
href="/favicons/apple-touch-icon.png"
|
|
/>
|
|
<link rel="icon" type="image/png" sizes="32x32" href="/favicons/favicon-32x32.png" />
|
|
<link rel="icon" type="image/png" sizes="16x16" href="/favicons/favicon-16x16.png" />
|
|
<link rel="manifest" href="/favicons/site.webmanifest" />
|
|
<meta httpEquiv="Content-Language" content="en" />
|
|
</Head>
|
|
<body>
|
|
<Layout
|
|
banner={
|
|
<Banner storageKey="docs-launch">
|
|
<div className="flex justify-center items-center gap-2">
|
|
Welcome to the new DocsGPT docs!
|
|
</div>
|
|
</Banner>
|
|
}
|
|
navbar={navbar}
|
|
footer={footer}
|
|
pageMap={await getPageMap()}
|
|
{...themeConfig}
|
|
>
|
|
{children}
|
|
</Layout>
|
|
<DocsGPTChatWidget />
|
|
<Analytics />
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|