layout.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* eslint-disable @next/next/no-page-custom-font */
  2. import "./styles/globals.scss";
  3. import "./styles/markdown.scss";
  4. import "./styles/prism.scss";
  5. import process from "child_process";
  6. import { ACCESS_CODES, IS_IN_DOCKER } from "./api/access";
  7. let COMMIT_ID: string | undefined;
  8. try {
  9. COMMIT_ID = process
  10. .execSync("git rev-parse --short HEAD")
  11. .toString()
  12. .trim();
  13. } catch (e) {
  14. console.error("No git or not from git repo.")
  15. }
  16. export const metadata = {
  17. title: "ChatGPT Next Web",
  18. description: "Your personal ChatGPT Chat Bot.",
  19. appleWebApp: {
  20. title: "ChatGPT Next Web",
  21. statusBarStyle: "black-translucent",
  22. },
  23. themeColor: "#fafafa"
  24. };
  25. function Meta() {
  26. const metas = {
  27. version: COMMIT_ID ?? "unknown",
  28. access: (ACCESS_CODES.size > 0 || IS_IN_DOCKER) ? "enabled" : "disabled",
  29. };
  30. return (
  31. <>
  32. {Object.entries(metas).map(([k, v]) => (
  33. <meta name={k} content={v} key={k} />
  34. ))}
  35. </>
  36. );
  37. }
  38. export default function RootLayout({
  39. children,
  40. }: {
  41. children: React.ReactNode;
  42. }) {
  43. return (
  44. <html lang="en">
  45. <head>
  46. <meta
  47. name="viewport"
  48. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
  49. />
  50. <Meta />
  51. <link rel="manifest" href="/site.webmanifest"></link>
  52. <link rel="preconnect" href="https://fonts.googleapis.com"></link>
  53. <link rel="preconnect" href="https://fonts.gstatic.com"></link>
  54. <link
  55. href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;700;900&display=swap"
  56. rel="stylesheet"
  57. ></link>
  58. <script src="/serviceWorkerRegister.js" defer></script>
  59. </head>
  60. <body>{children}</body>
  61. </html>
  62. );
  63. }