layout.tsx 1.9 KB

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