layout.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 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: "black-translucent",
  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. <link rel="manifest" href="/site.webmanifest"></link>
  53. <link rel="preconnect" href="https://fonts.googleapis.com"></link>
  54. <link rel="preconnect" href="https://fonts.gstatic.com"></link>
  55. <link
  56. href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;700;900&display=swap"
  57. rel="stylesheet"
  58. ></link>
  59. <script src="/serviceWorkerRegister.js" defer></script>
  60. </head>
  61. <body>{children}</body>
  62. </html>
  63. );
  64. }