fix: dynamic site name

This commit is contained in:
shinya
2025-06-30 23:48:35 +08:00
parent 240764e81b
commit 0563f2478e
4 changed files with 30 additions and 12 deletions

View File

@@ -4,7 +4,10 @@ import Link from 'next/link';
import { ThemeToggle } from './ThemeToggle';
export const dynamic = 'force-dynamic';
const MobileHeader = () => {
const siteName = process.env.NEXT_PUBLIC_SITE_NAME || 'MoonTV';
return (
<header className='md:hidden relative w-full bg-white/70 backdrop-blur-xl border-b border-gray-200/50 shadow-sm dark:bg-gray-900/70 dark:border-gray-700/50'>
<div className='h-12 flex items-center justify-center'>
@@ -12,7 +15,7 @@ const MobileHeader = () => {
href='/'
className='text-2xl font-bold text-green-600 tracking-tight hover:opacity-80 transition-opacity'
>
{process.env.NEXT_PUBLIC_SITE_NAME || 'MoonTV'}
{siteName}
</Link>
</div>
<div className='absolute top-1/2 right-4 -translate-y-1/2'>

View File

@@ -33,13 +33,17 @@ const SidebarContext = createContext<SidebarContextType>({
export const useSidebar = () => useContext(SidebarContext);
// 可替换为你自己的 logo 图片
const Logo = () => (
interface LogoProps {
siteName: string;
}
const Logo = ({ siteName }: LogoProps) => (
<Link
href='/'
className='flex items-center justify-center h-16 select-none hover:opacity-80 transition-opacity duration-200'
>
<span className='text-2xl font-bold text-green-600 tracking-tight'>
{process.env.NEXT_PUBLIC_SITE_NAME || 'MoonTV'}
{siteName}
</span>
</Link>
);
@@ -56,6 +60,8 @@ declare global {
}
}
export const dynamic = 'force-dynamic';
const Sidebar = ({ onToggle, activePath = '/' }: SidebarProps) => {
const router = useRouter();
const pathname = usePathname();
@@ -158,6 +164,8 @@ const Sidebar = ({ onToggle, activePath = '/' }: SidebarProps) => {
{ icon: VenetianMask, label: '日漫', href: '/douban?type=tv&tag=日本动画' },
];
const siteName = process.env.NEXT_PUBLIC_SITE_NAME || 'MoonTV';
return (
<SidebarContext.Provider value={contextValue}>
{/* 在移动端隐藏侧边栏 */}
@@ -181,7 +189,7 @@ const Sidebar = ({ onToggle, activePath = '/' }: SidebarProps) => {
}`}
>
<div className='w-[calc(100%-4rem)] flex justify-center'>
{!isCollapsed && <Logo />}
{!isCollapsed && <Logo siteName={siteName} />}
</div>
</div>
<button