feat: add BuildInfo component to display build time and update Docker workflow to pass build time as environment variable
This commit is contained in:
32
src/components/BuildInfo.tsx
Normal file
32
src/components/BuildInfo.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
export default function BuildInfo() {
|
||||
const buildTime = process.env.BUILD_TIME;
|
||||
|
||||
if (!buildTime) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const buildDate = new Date(buildTime);
|
||||
const now = new Date();
|
||||
const diffMs = now.getTime() - buildDate.getTime();
|
||||
|
||||
let timeAgo = '';
|
||||
const diffMins = Math.floor(diffMs / 60000);
|
||||
const diffHours = Math.floor(diffMs / 3600000);
|
||||
const diffDays = Math.floor(diffMs / 86400000);
|
||||
|
||||
if (diffMins < 60) {
|
||||
timeAgo = `${diffMins} minute${diffMins !== 1 ? 's' : ''} ago`;
|
||||
} else if (diffHours < 24) {
|
||||
timeAgo = `${diffHours} hour${diffHours !== 1 ? 's' : ''} ago`;
|
||||
} else {
|
||||
timeAgo = `${diffDays} day${diffDays !== 1 ? 's' : ''} ago`;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="bg-gray-50 border border-gray-200 rounded-lg p-4 text-sm">
|
||||
<p className="text-gray-700">
|
||||
<span className="font-semibold">Build Time:</span> {buildDate.toLocaleString()} ({timeAgo})
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user