Skip to content

Commit 6fd2622

Browse files
committed
Fix version
1 parent dca9d34 commit 6fd2622

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

src/app/layout.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import type { Metadata } from "next";
22
import type { ReactNode } from "react";
3-
import { usbVersion } from "../shared/utils";
43

54
export const metadata: Metadata = {
6-
title: usbVersion()
5+
title: "Hiroki Usuba"
76
};
87

98
export default function Layout({ children }: { children: ReactNode }) {

src/components/Header.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
1+
"use client";
2+
3+
import { useEffect, useRef, useState } from "react";
14
import Colors from "../shared/colors";
25
import { usbVersion } from "../shared/utils";
36

47
const links = ["Publications", "Awards", "Education", "Work", "Others"];
58

69
export default function Header() {
10+
const [version, setVersion] = useState(usbVersion());
11+
const animationRef = useRef(-1);
12+
13+
useEffect(() => {
14+
const loop = () => {
15+
const nextVersion = usbVersion();
16+
17+
document.title = nextVersion;
18+
setVersion(nextVersion);
19+
animationRef.current = requestAnimationFrame(loop);
20+
};
21+
22+
loop();
23+
24+
return () => {
25+
cancelAnimationFrame(animationRef.current);
26+
};
27+
}, []);
28+
729
return (
830
<div
931
css={{
@@ -26,7 +48,7 @@ export default function Header() {
2648
paddingLeft: "1rem"
2749
}}
2850
>
29-
<div css={{ marginRight: "1rem" }}>{usbVersion()}</div>
51+
<div css={{ marginRight: "1rem" }}>{version}</div>
3052
{links.map((a, i) => {
3153
return (
3254
<a

0 commit comments

Comments
 (0)