mirror of
https://github.com/YuzuZensai/Pien-Studio.git
synced 2026-09-02 14:18:35 +00:00
✨ feat: ui commit hash versioning
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
import { NextResponse } from "next/server";
|
||||||
|
import { execSync } from "child_process";
|
||||||
|
|
||||||
|
export function GET() {
|
||||||
|
const hash = execSync("git rev-parse --short HEAD").toString().trim();
|
||||||
|
return NextResponse.json({ hash });
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
|
import { Footer } from "../components/footer";
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "pien.studio",
|
title: "pien.studio",
|
||||||
@@ -10,7 +11,10 @@ export const metadata: Metadata = {
|
|||||||
export default function RootLayout({ children }: { children: ReactNode }) {
|
export default function RootLayout({ children }: { children: ReactNode }) {
|
||||||
return (
|
return (
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<body>{children}</body>
|
<body>
|
||||||
|
{children}
|
||||||
|
<Footer />
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
export function Footer() {
|
||||||
|
const [hash, setHash] = useState<string>("...");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetch("/api/commit-hash")
|
||||||
|
.then((res) => res.json())
|
||||||
|
.then((data) => setHash(data.hash))
|
||||||
|
.catch(() => setHash("unknown"));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<footer className="fixed bottom-2 right-4 py-1 pointer-events-none">
|
||||||
|
<span className="text-xs text-gray-400 font-mono">{hash}</span>
|
||||||
|
</footer>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user