Skip to content

Commit

Permalink
feat: 添加 Umami 统计分析代码
Browse files Browse the repository at this point in the history
  • Loading branch information
baiwumm committed Jan 8, 2025
1 parent 4f037fe commit 87d9a9b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type { Metadata } from 'next';
import { NextIntlClientProvider } from 'next-intl';
import { getLocale, getMessages } from 'next-intl/server';

import UmamiAnalytics from '@/components/Analytics/UmamiAnalytics'; // Umami Analytics
import FullLoading from '@/components/FullLoading'; // 全局 Loading
import GlobalLayout from '@/components/GlobalLayout'; // 全局布局
import ThemeProvider from '@/components/ThemeProvider';
Expand All @@ -31,6 +32,8 @@ export default async function RootLayout({
const messages = await getMessages();
return (
<html lang={locale} suppressHydrationWarning>
{/* umami - 站点统计分析 */}
<UmamiAnalytics />
<body>
<NextUIProvider>
<NextIntlClientProvider messages={messages}>
Expand Down
15 changes: 15 additions & 0 deletions src/components/Analytics/UmamiAnalytics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* @Author: 白雾茫茫丶<baiwumm.com>
* @Date: 2025-01-08 09:21:56
* @LastEditors: 白雾茫茫丶<baiwumm.com>
* @LastEditTime: 2025-01-08 09:22:25
* @Description: Umami 统计分析
*/
import Script from 'next/script';

const UmamiAnalytics = () => {
return process.env.UMAMI_ANALYTICS && process.env.NODE_ENV === 'production' ? (
<Script src="https://umami.baiwumm.com/script.js" data-website-id={process.env.UMAMI_ANALYTICS} />
) : null;
};
export default UmamiAnalytics;

0 comments on commit 87d9a9b

Please sign in to comment.