Xianbao QIAN commited on
Commit
1f1c117
β€’
1 Parent(s): c88f96b

show navigation bar

Browse files
src/pages/heatmap/index.tsx CHANGED
@@ -3,26 +3,39 @@ import ActivityCalendar from 'react-activity-calendar';
3
  import { Tooltip } from '@mui/material';
4
  import { PROVIDERS_MAP } from '../../utils/providers';
5
  import { CalendarData, fetchAllModelData, generateCalendarData, aggregateCalendarData } from '../../utils/modelData';
 
6
 
7
  interface OpenSourceHeatmapProps {
8
  calendarData: CalendarData;
9
  }
10
 
11
  export const getStaticProps = async () => {
12
- const allModels = await fetchAllModelData();
13
- const calendarData = generateCalendarData(allModels);
 
 
14
 
15
- return {
16
- props: {
17
- calendarData,
18
- },
19
- revalidate: 3600, // Revalidate every hour
20
- };
 
 
 
 
 
 
 
 
 
 
 
21
  };
22
 
23
  const OpenSourceHeatmap: React.FC<OpenSourceHeatmapProps> = ({ calendarData }) => {
24
  const [isLoading, setIsLoading] = useState(true);
25
- const aggregatedData = aggregateCalendarData(calendarData);
26
 
27
  useEffect(() => {
28
  if (calendarData && Object.keys(calendarData).length > 0) {
@@ -32,11 +45,20 @@ const OpenSourceHeatmap: React.FC<OpenSourceHeatmapProps> = ({ calendarData }) =
32
 
33
  return (
34
  <div className="w-full max-w-screen-lg mx-auto p-4">
35
- <h1 className="text-3xl lg:text-5xl mt-16 font-bold text-center mb-2">Chinese AI Open Source Heatmap πŸ€—</h1>
36
- <p className="text-center text-sm mb-8">
37
- The top AI labs and model releases from the awesome Chinese AI community.<br />
38
- Huge thanks to Caleb for the excellent original work. <a href="https://huggingface.co/spaces/cfahlgren1/model-release-heatmap" target="_blank">Link</a> to the original repo
39
- </p>
 
 
 
 
 
 
 
 
 
40
  {isLoading ? (
41
  <p className="text-center">Loading...</p>
42
  ) : (
@@ -47,7 +69,7 @@ const OpenSourceHeatmap: React.FC<OpenSourceHeatmapProps> = ({ calendarData }) =
47
  <div className="w-full overflow-x-auto">
48
  <div className="inline-block mx-auto">
49
  <ActivityCalendar
50
- data={aggregatedData}
51
  theme={{
52
  dark: ['#161b22', '#4CAF50'],
53
  light: ['#e0e0e0', '#4CAF50'],
 
3
  import { Tooltip } from '@mui/material';
4
  import { PROVIDERS_MAP } from '../../utils/providers';
5
  import { CalendarData, fetchAllModelData, generateCalendarData, aggregateCalendarData } from '../../utils/modelData';
6
+ import Link from 'next/link';
7
 
8
  interface OpenSourceHeatmapProps {
9
  calendarData: CalendarData;
10
  }
11
 
12
  export const getStaticProps = async () => {
13
+ try {
14
+ const modelData = await fetchAllModelData();
15
+ const calendarData = generateCalendarData(modelData);
16
+ const aggregatedData = aggregateCalendarData(calendarData);
17
 
18
+ return {
19
+ props: {
20
+ calendarData: aggregatedData,
21
+ },
22
+ // Revalidate every 12 hours
23
+ revalidate: 43200,
24
+ };
25
+ } catch (error) {
26
+ console.error('Error in getStaticProps:', error);
27
+ return {
28
+ props: {
29
+ calendarData: {},
30
+ },
31
+ // Retry more frequently if there was an error
32
+ revalidate: 3600,
33
+ };
34
+ }
35
  };
36
 
37
  const OpenSourceHeatmap: React.FC<OpenSourceHeatmapProps> = ({ calendarData }) => {
38
  const [isLoading, setIsLoading] = useState(true);
 
39
 
40
  useEffect(() => {
41
  if (calendarData && Object.keys(calendarData).length > 0) {
 
45
 
46
  return (
47
  <div className="w-full max-w-screen-lg mx-auto p-4">
48
+ <div className="flex justify-between items-center mb-8">
49
+ <div>
50
+ <h1 className="text-3xl lg:text-4xl font-bold mb-2">Chinese AI Open Source Heatmap πŸ€—</h1>
51
+ <p className="text-gray-600 dark:text-gray-400">
52
+ Visualize the activity of Chinese AI models and datasets
53
+ </p>
54
+ </div>
55
+ <Link
56
+ href="/trend"
57
+ className="px-4 py-2 rounded-lg bg-blue-500 text-white hover:bg-blue-600 transition-colors"
58
+ >
59
+ View Trends
60
+ </Link>
61
+ </div>
62
  {isLoading ? (
63
  <p className="text-center">Loading...</p>
64
  ) : (
 
69
  <div className="w-full overflow-x-auto">
70
  <div className="inline-block mx-auto">
71
  <ActivityCalendar
72
+ data={calendarData}
73
  theme={{
74
  dark: ['#161b22', '#4CAF50'],
75
  light: ['#e0e0e0', '#4CAF50'],
src/pages/index.tsx CHANGED
@@ -1,21 +1,12 @@
1
- import Link from 'next/link';
 
2
 
3
  export default function Home() {
4
- return (
5
- <div className="w-full max-w-screen-lg mx-auto p-4">
6
- <h1 className="text-3xl lg:text-5xl mt-16 font-bold text-center mb-2">Chinese AI Open Source Heatmap πŸ€—</h1>
7
- <p className="text-center text-sm mb-8">
8
- The top AI labs and model releases from the awesome Chinese AI community.<br />
9
- Huge thanks to Caleb for the excellent original work. <a href="https://huggingface.co/spaces/cfahlgren1/model-release-heatmap" target="_blank">Link</a> to the original repo
10
- </p>
11
- <div className="flex justify-center mt-8">
12
- <Link
13
- href="/heatmap"
14
- className="text-xl text-blue-600 hover:text-blue-800 hover:underline"
15
- >
16
- View Heatmap
17
- </Link>
18
- </div>
19
- </div>
20
- );
21
  }
 
1
+ import { useEffect } from 'react';
2
+ import { useRouter } from 'next/router';
3
 
4
  export default function Home() {
5
+ const router = useRouter();
6
+
7
+ useEffect(() => {
8
+ router.replace('/trend');
9
+ }, []);
10
+
11
+ return null;
 
 
 
 
 
 
 
 
 
 
12
  }
src/pages/trend/index.tsx CHANGED
@@ -19,6 +19,7 @@ import {
19
  DetailedModelData,
20
  convertToCSV
21
  } from '../../utils/modelData';
 
22
 
23
  interface TrendProps {
24
  monthlyData: MonthlyActivity[];
@@ -156,8 +157,21 @@ const TrendPage: React.FC<TrendProps> = ({ monthlyData = [], totalData = [], det
156
  }
157
 
158
  return (
159
- <div className="w-full max-w-screen-xl mx-auto p-4">
160
- <h1 className="text-3xl lg:text-5xl mt-16 font-bold text-center mb-2 dark:text-white">Chinese AI Model Release Trends πŸ“ˆ</h1>
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  <p className="text-center text-sm mb-8 dark:text-gray-300">
162
  Track the growth of Chinese AI models and datasets over time
163
  </p>
@@ -376,23 +390,19 @@ const TrendPage: React.FC<TrendProps> = ({ monthlyData = [], totalData = [], det
376
 
377
  export const getStaticProps = async () => {
378
  try {
379
- const allModels = await fetchAllModelData();
380
-
381
- if (!allModels || allModels.length === 0) {
382
- throw new Error('Failed to fetch model data');
383
- }
384
-
385
- const monthlyData = generateMonthlyData(allModels);
386
  const totalData = getTotalMonthlyData(monthlyData);
387
- const detailedData = processDetailedModelData(allModels);
388
 
389
  return {
390
  props: {
391
  monthlyData,
392
  totalData,
393
- detailedData,
394
  },
395
- revalidate: 3600, // Revalidate every hour
 
396
  };
397
  } catch (error) {
398
  console.error('Error in getStaticProps:', error);
@@ -400,10 +410,10 @@ export const getStaticProps = async () => {
400
  props: {
401
  monthlyData: [],
402
  totalData: [],
403
- detailedData: [],
404
- error: 'Failed to load data. Please try again later.'
405
  },
406
- revalidate: 60, // Retry sooner if there was an error
 
407
  };
408
  }
409
  };
 
19
  DetailedModelData,
20
  convertToCSV
21
  } from '../../utils/modelData';
22
+ import Link from 'next/link';
23
 
24
  interface TrendProps {
25
  monthlyData: MonthlyActivity[];
 
157
  }
158
 
159
  return (
160
+ <div className="w-full max-w-screen-lg mx-auto p-4">
161
+ <div className="flex justify-between items-center mb-8">
162
+ <div>
163
+ <h1 className="text-3xl lg:text-4xl font-bold mb-2">Chinese AI Open Source Trends πŸ€—</h1>
164
+ <p className="text-gray-600 dark:text-gray-400">
165
+ Track the growth of Chinese AI models and datasets over time
166
+ </p>
167
+ </div>
168
+ <Link
169
+ href="/heatmap"
170
+ className="px-4 py-2 rounded-lg bg-blue-500 text-white hover:bg-blue-600 transition-colors"
171
+ >
172
+ View Heatmap
173
+ </Link>
174
+ </div>
175
  <p className="text-center text-sm mb-8 dark:text-gray-300">
176
  Track the growth of Chinese AI models and datasets over time
177
  </p>
 
390
 
391
  export const getStaticProps = async () => {
392
  try {
393
+ const modelData = await fetchAllModelData();
394
+ const monthlyData = generateMonthlyData(modelData);
 
 
 
 
 
395
  const totalData = getTotalMonthlyData(monthlyData);
396
+ const filteredModels = processDetailedModelData(modelData);
397
 
398
  return {
399
  props: {
400
  monthlyData,
401
  totalData,
402
+ filteredModels,
403
  },
404
+ // Revalidate every 12 hours
405
+ revalidate: 43200,
406
  };
407
  } catch (error) {
408
  console.error('Error in getStaticProps:', error);
 
410
  props: {
411
  monthlyData: [],
412
  totalData: [],
413
+ filteredModels: {},
 
414
  },
415
+ // Retry more frequently if there was an error
416
+ revalidate: 3600,
417
  };
418
  }
419
  };