Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sidebar): add SIDEBAR_TITLE and SIDEBAR_SUBTITLE config for cust… #5012

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,13 @@ ANTHROPIC_API_VERSION=
ANTHROPIC_URL=

### (optional)
WHITE_WEBDEV_ENDPOINTS=
WHITE_WEBDEV_ENDPOINTS=

### custom sidebar title.(optional)
SITE_TITLE=

### custom sidebar subtitle.(optional)
SITE_DESCRIPTION=

## custom sidebar logo url.(optional)
SITE_LOGO_URL=
16 changes: 8 additions & 8 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-

-
name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
Expand All @@ -29,16 +29,16 @@ jobs:
tags: |
type=raw,value=latest
type=ref,event=tag
-

-
name: Set up QEMU
uses: docker/setup-qemu-action@v2

-
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-

-
name: Build and push Docker image
uses: docker/build-push-action@v4
with:
Expand All @@ -49,4 +49,4 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

9 changes: 4 additions & 5 deletions app/components/exporter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { EXPORT_MESSAGE_CLASS_NAME } from "../constant";
import { getClientConfig } from "../config/client";
import { type ClientApi, getClientApi } from "../client/api";
import { getMessageTextContent } from "../utils";
import { getServerSideConfig } from "@/app/config/server";

const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
loading: () => <LoadingIcon />,
Expand Down Expand Up @@ -515,7 +516,7 @@ export function ImagePreviewer(props: {
dom.innerHTML = dom.innerHTML; // Refresh the content of the preview by resetting its HTML for fix a bug glitching
}
};

const { siteTitle, siteDescription } = getServerSideConfig();
return (
<div className={styles["image-previewer"]}>
<PreviewActions
Expand All @@ -539,10 +540,8 @@ export function ImagePreviewer(props: {
</div>

<div>
<div className={styles["main-title"]}>NextChat</div>
<div className={styles["sub-title"]}>
github.com/Yidadaa/ChatGPT-Next-Web
</div>
<div className={styles["main-title"]}>{siteTitle}</div>
<div className={styles["sub-title"]}>{siteDescription}</div>
<div className={styles["icons"]}>
<ExportAvatar avatar={config.avatar} />
<span className={styles["icon-space"]}>&</span>
Expand Down
12 changes: 5 additions & 7 deletions app/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { Link, useNavigate } from "react-router-dom";
import { isIOS, useMobileScreen } from "../utils";
import dynamic from "next/dynamic";
import { showConfirm, showToast } from "./ui-lib";
import { getServerSideConfig } from "../config/server";

const ChatList = dynamic(async () => (await import("./chat-list")).ChatList, {
loading: () => null,
Expand Down Expand Up @@ -130,7 +131,6 @@ function useDragSideBar() {

export function SideBar(props: { className?: string }) {
const chatStore = useChatStore();

// drag side bar
const { onDragStart, shouldNarrow } = useDragSideBar();
const navigate = useNavigate();
Expand All @@ -140,7 +140,7 @@ export function SideBar(props: { className?: string }) {
() => isIOS() && isMobileScreen,
[isMobileScreen],
);

const { siteTitle, siteDescription, siteLogURL } = getServerSideConfig();
useHotKey();

return (
Expand All @@ -155,13 +155,11 @@ export function SideBar(props: { className?: string }) {
>
<div className={styles["sidebar-header"]} data-tauri-drag-region>
<div className={styles["sidebar-title"]} data-tauri-drag-region>
NextChat
</div>
<div className={styles["sidebar-sub-title"]}>
Build your own AI assistant.
{siteTitle}
</div>
<div className={styles["sidebar-sub-title"]}>{siteDescription}</div>
<div className={styles["sidebar-logo"] + " no-dark"}>
<ChatGptIcon />
{siteLogURL ? <img src={siteLogURL}></img> : <ChatGptIcon />}
</div>
</div>

Expand Down
16 changes: 14 additions & 2 deletions app/config/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,18 @@ declare global {

// custom template for preprocessing user input
DEFAULT_INPUT_TEMPLATE?: string;

// custom site title
SITE_TITLE?: string;
// custom site description
SITE_DESCRIPTION?: string;
SITE_LOGO_URL?: string;
}
}
}

const ACCESS_CODES = (function getAccessCodes(): Set<string> {
const code = process.env.CODE;

try {
const codes = (code?.split(",") ?? [])
.filter((v) => !!v)
Expand Down Expand Up @@ -125,7 +130,11 @@ export const getServerSideConfig = () => {
const allowedWebDevEndpoints = (
process.env.WHITE_WEBDEV_ENDPOINTS ?? ""
).split(",");

// custom site
const siteTitle = process.env.SITE_TITLE ?? "NextChat";
const siteDescription =
process.env.SITE_DESCRIPTION ?? "Build your own AI assistant.";
const siteLogURL = process.env.SITE_LOGO_URL ?? "";
return {
baseUrl: process.env.BASE_URL,
apiKey: getApiKey(process.env.OPENAI_API_KEY),
Expand Down Expand Up @@ -174,5 +183,8 @@ export const getServerSideConfig = () => {
customModels,
defaultModel,
allowedWebDevEndpoints,
siteTitle,
siteDescription,
siteLogURL,
};
};
9 changes: 6 additions & 3 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { GoogleTagManager } from "@next/third-parties/google";
const serverConfig = getServerSideConfig();

export const metadata: Metadata = {
title: "NextChat",
title: serverConfig.siteTitle,
description: "Your personal ChatGPT Chat Bot.",
appleWebApp: {
title: "NextChat",
title: serverConfig.siteTitle,
statusBarStyle: "default",
},
};
Expand All @@ -37,7 +37,10 @@ export default function RootLayout({
<html lang="en">
<head>
<meta name="config" content={JSON.stringify(getClientConfig())} />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<link rel="manifest" href="/site.webmanifest"></link>
<script src="/serviceWorkerRegister.js" defer></script>
</head>
Expand Down
6 changes: 4 additions & 2 deletions app/store/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import Locale from "../locales";
import { use } from "react";
import { useAppConfig } from ".";
import { ClientApi } from "../client/api";
import { getServerSideConfig } from "@/app/config/server";

const ONE_MINUTE = 60 * 1000;
const isApp = !!getClientConfig()?.isApp;
const serverConfig = getServerSideConfig();

function formatVersionDate(t: string) {
const d = new Date(+t);
Expand Down Expand Up @@ -106,7 +108,7 @@ export const useUpdateStore = createPersistStore(
if (version === remoteId) {
// Show a notification using Tauri
window.__TAURI__?.notification.sendNotification({
title: "NextChat",
title: `${serverConfig.siteTitle}`,
body: `${Locale.Settings.Update.IsLatest}`,
icon: `${ChatGptIcon.src}`,
sound: "Default",
Expand All @@ -116,7 +118,7 @@ export const useUpdateStore = createPersistStore(
Locale.Settings.Update.FoundUpdate(`${remoteId}`);
// Show a notification for the new version using Tauri
window.__TAURI__?.notification.sendNotification({
title: "NextChat",
title: `${serverConfig.siteTitle}`,
body: updateMessage,
icon: `${ChatGptIcon.src}`,
sound: "Default",
Expand Down
Loading