hash to id

This commit is contained in:
imnyang 2025-05-08 22:23:20 +09:00
commit 46bb4617d4
2 changed files with 16 additions and 1 deletions

View file

@ -8,6 +8,21 @@ export function Page() {
const [age, setAge] = useState<number>(0); const [age, setAge] = useState<number>(0);
const [post, setPost] = useState<any>({}); const [post, setPost] = useState<any>({});
useEffect(() => {
const scrollToHash = () => {
const hash = window.location.hash.substring(1);
if (hash) {
const element = document.getElementById(hash);
if (element) {
setTimeout(() => {
element.scrollIntoView({ behavior: "smooth" });
}, 100);
}
}
};
scrollToHash();
}, []);
useEffect(() => { useEffect(() => {
// 나이 계산 // 나이 계산
const referenceDate = new Date(2010, 10, 8); // 2010년 11월 8일 (0-indexed) const referenceDate = new Date(2010, 10, 8); // 2010년 11월 8일 (0-indexed)

View file

@ -176,7 +176,7 @@ export default function Timeline() {
}, [isVisible, count]); }, [isVisible, count]);
return ( return (
<div ref={TimelineRef} className="w-full flex flex-col items-center justify-center mt-8"> <div id="timeline" ref={TimelineRef} className="w-full flex flex-col items-center justify-center mt-8">
<div className="w-full"> <div className="w-full">
<h1 className="text-2xl font-bold mb-4 w-full">🌠 </h1> <h1 className="text-2xl font-bold mb-4 w-full">🌠 </h1>
<p> {count} !</p> <p> {count} !</p>