Răsfoiți Sursa

feat: optimize loading speed, enhance SEO, replace GPT Actions with SecondSelf

- Defer 3D Mini Cooper model behind click-to-load (static image by default)
- Lazy-load AnimatedEmoji, CardStack, WebAgent, Chatbot via next/dynamic
- Add Intersection Observer for Map, IconCloud, Mini cards
- Compress GLB with Draco (3.6MB → 2.4MB)
- Add JSON-LD structured data (Person + WebSite schemas)
- Add generateMetadata for blog pages with Article schema
- Add metadataBase, canonical URLs, OG image, googleBot directives
- Convert robots.txt to app/robots.ts, enhance sitemap with priorities
- Replace GPT Actions card with SecondSelf project

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
rriecc 9 luni în urmă
părinte
comite
2073e6fcb4

+ 62 - 5
app/blog/[blogId]/page.tsx

@@ -1,8 +1,42 @@
+import { Metadata } from "next";
+
 import { NotionPage } from "@/components/notion-page";
 import { getPageContent } from "@/lib/notion";
+import { siteConfig } from "@/config/site";
 
 export const revalidate = 0;
 
+export async function generateMetadata({
+  params,
+}: {
+  params: Promise<{ blogId: string }>;
+}): Promise<Metadata> {
+  const { blogId } = await params;
+  const { title } = await getPageContent(blogId);
+
+  const postTitle = title || "Blog Post";
+
+  return {
+    title: postTitle,
+    description: `${postTitle} - by ${siteConfig.author}`,
+    alternates: {
+      canonical: `/blog/${blogId}`,
+    },
+    openGraph: {
+      title: postTitle,
+      description: `${postTitle} - by ${siteConfig.author}`,
+      type: "article",
+      url: `/blog/${blogId}`,
+      authors: [siteConfig.author],
+    },
+    twitter: {
+      card: "summary_large_image",
+      title: postTitle,
+      description: `${postTitle} - by ${siteConfig.author}`,
+    },
+  };
+}
+
 export default async function Page({
   params,
 }: {
@@ -11,11 +45,34 @@ export default async function Page({
   const { blogId } = await params;
   const { recordMap, title } = await getPageContent(blogId);
 
+  const jsonLd = {
+    "@context": "https://schema.org",
+    "@type": "Article",
+    headline: title,
+    author: {
+      "@type": "Person",
+      name: siteConfig.author,
+      url: siteConfig.url,
+    },
+    publisher: {
+      "@type": "Person",
+      name: siteConfig.author,
+      url: siteConfig.url,
+    },
+    url: `${siteConfig.url}/blog/${blogId}`,
+  };
+
   return (
-    <NotionPage
-      recordMap={recordMap}
-      rootPageId={blogId}
-      title={title ?? undefined}
-    />
+    <>
+      <script
+        type="application/ld+json"
+        dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
+      />
+      <NotionPage
+        recordMap={recordMap}
+        rootPageId={blogId}
+        title={title ?? undefined}
+      />
+    </>
   );
 }

+ 18 - 0
app/blog/page.tsx

@@ -1,9 +1,27 @@
+import { Metadata } from "next";
+
 import { customMapImageUrl, getAllBlogPosts } from "@/lib/notion";
 import { notionBlogConfig } from "@/config/site";
 import { BlogList } from "@/components/blog-list";
 
 export const revalidate = 0;
 
+export const metadata: Metadata = {
+  title: "Blog",
+  description:
+    "Read Eric Wu's blog posts on software engineering, AI, agentic systems, full stack development, and more.",
+  alternates: {
+    canonical: "/blog",
+  },
+  openGraph: {
+    title: "Blog",
+    description:
+      "Read Eric Wu's blog posts on software engineering, AI, agentic systems, full stack development, and more.",
+    type: "website",
+    url: "/blog",
+  },
+};
+
 export default async function Page() {
   const blogPosts = await getAllBlogPosts(notionBlogConfig.blogParentId);
 

+ 65 - 3
app/layout.tsx

@@ -14,30 +14,50 @@ import { siteConfig } from "@/config/site";
 import { fontOleoScript, fontUbuntu } from "@/config/fonts";
 
 export const metadata: Metadata = {
+  metadataBase: new URL(siteConfig.url),
   title: {
     default: siteConfig.name,
     template: `%s - ${siteConfig.name}`,
   },
   description: siteConfig.description,
   keywords: siteConfig.keywords,
-  authors: [{ name: siteConfig.author, url: "https://ericwu.me" }],
+  authors: [{ name: siteConfig.author, url: siteConfig.url }],
   creator: siteConfig.author,
+  alternates: {
+    canonical: "/",
+  },
   openGraph: {
     type: "website",
     locale: "en_US",
-    url: "https://ericwu.me",
+    url: siteConfig.url,
     siteName: siteConfig.name,
     title: siteConfig.name,
     description: siteConfig.description,
+    images: [
+      {
+        url: "/og-image.png",
+        width: 1200,
+        height: 630,
+        alt: siteConfig.name,
+      },
+    ],
   },
   twitter: {
     card: "summary_large_image",
     title: siteConfig.name,
     description: siteConfig.description,
+    images: ["/og-image.png"],
   },
   robots: {
     index: true,
     follow: true,
+    googleBot: {
+      index: true,
+      follow: true,
+      "max-video-preview": -1,
+      "max-image-preview": "large",
+      "max-snippet": -1,
+    },
   },
   icons: {
     icon: "/favicon.ico",
@@ -51,6 +71,43 @@ export const viewport: Viewport = {
   ],
 };
 
+const jsonLd = {
+  "@context": "https://schema.org",
+  "@graph": [
+    {
+      "@type": "WebSite",
+      "@id": `${siteConfig.url}/#website`,
+      url: siteConfig.url,
+      name: siteConfig.name,
+      description: siteConfig.description,
+      inLanguage: "en-US",
+    },
+    {
+      "@type": "Person",
+      "@id": `${siteConfig.url}/#person`,
+      name: "Eric Wu",
+      alternateName: "Chengxiang Wu",
+      url: siteConfig.url,
+      jobTitle: "Software Development Engineer",
+      worksFor: {
+        "@type": "Organization",
+        name: "Amazon Web Services",
+      },
+      alumniOf: [
+        {
+          "@type": "CollegeOrUniversity",
+          name: "University of California, Los Angeles",
+        },
+        {
+          "@type": "CollegeOrUniversity",
+          name: "Purdue University",
+        },
+      ],
+      sameAs: [siteConfig.links.github, siteConfig.links.linkedin],
+    },
+  ],
+};
+
 export default function RootLayout({
   children,
 }: {
@@ -58,7 +115,12 @@ export default function RootLayout({
 }) {
   return (
     <html suppressHydrationWarning lang="en">
-      <head />
+      <head>
+        <script
+          type="application/ld+json"
+          dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
+        />
+      </head>
       <body
         className={clsx(
           fontUbuntu.className,

+ 16 - 0
app/robots.ts

@@ -0,0 +1,16 @@
+import { MetadataRoute } from "next";
+
+import { siteConfig } from "@/config/site";
+
+export default function robots(): MetadataRoute.Robots {
+  return {
+    rules: [
+      {
+        userAgent: "*",
+        allow: "/",
+        disallow: ["/api/"],
+      },
+    ],
+    sitemap: `${siteConfig.url}/sitemap.xml`,
+  };
+}

+ 20 - 12
app/sitemap.ts

@@ -1,11 +1,9 @@
 import { MetadataRoute } from "next";
 
-import { notionBlogConfig } from "@/config/site";
+import { notionBlogConfig, siteConfig } from "@/config/site";
 import { getAllBlogPosts } from "@/lib/notion";
 
-const WEBSITE_HOST_URL = process.env.SITE_URL;
-
-type changeFrequency =
+type ChangeFrequency =
   | "always"
   | "hourly"
   | "daily"
@@ -15,20 +13,30 @@ type changeFrequency =
   | "never";
 
 export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
-  let blogPosts = await getAllBlogPosts(notionBlogConfig.blogParentId);
-  const changeFrequency = "daily" as changeFrequency;
+  const blogPosts = await getAllBlogPosts(notionBlogConfig.blogParentId);
+  const changeFrequency: ChangeFrequency = "weekly";
 
   const blogs = blogPosts.map(({ id, createdAt }) => ({
-    url: `${WEBSITE_HOST_URL}/blog/${id}`,
+    url: `${siteConfig.url}/blog/${id}`,
     lastModified: createdAt.toISOString(),
     changeFrequency,
+    priority: 0.7,
   }));
 
-  const routes = ["", "/blog"].map((route) => ({
-    url: `${WEBSITE_HOST_URL}${route}`,
-    lastModified: new Date().toISOString(),
-    changeFrequency,
-  }));
+  const routes: MetadataRoute.Sitemap = [
+    {
+      url: siteConfig.url,
+      lastModified: new Date().toISOString(),
+      changeFrequency: "weekly" as ChangeFrequency,
+      priority: 1.0,
+    },
+    {
+      url: `${siteConfig.url}/blog`,
+      lastModified: new Date().toISOString(),
+      changeFrequency: "daily" as ChangeFrequency,
+      priority: 0.8,
+    },
+  ];
 
   return [...routes, ...blogs];
 }

+ 3 - 3
components/actions.tsx

@@ -12,7 +12,7 @@ const Actions = ({ photoUrl }: ActionsProps) => {
       <div className="absolute -bottom-32 md:-bottom-52 left-1/2 -translate-x-1/2 bg-cardPink w-64 h-56 md:w-96 md:h-96 rounded-full dark:hidden" />
       <div className="absolute top-16 md:top-36 -translate-y-1/2 left-20 md:left-44 transform -rotate-[30deg] rounded-2xl w-[80%]">
         <Image
-          alt="Actions"
+          alt="SecondSelf - AI Agent Social Network"
           className="w-full h-full rounded-2xl object-contain"
           height={1280}
           src={photoUrl}
@@ -24,10 +24,10 @@ const Actions = ({ photoUrl }: ActionsProps) => {
           <Link
             isExternal
             color="foreground"
-            href="https://action.simplegen.ai/"
+            href="https://secondself.com/"
           >
             <span className="text-sm md:text-medium text-nowrap hidden group-hover:block invisible group-hover:visible mr-1 animate-fade">
-              GPT Actions
+              SecondSelf
             </span>
           </Link>
           <GoArrowUpRight />

+ 79 - 8
components/home-client.tsx

@@ -2,7 +2,13 @@
 
 import { Tab, Tabs } from "@heroui/react";
 import { Responsive } from "react-grid-layout";
-import { useEffect, useState, useTransition } from "react";
+import {
+  useEffect,
+  useState,
+  useTransition,
+  useRef,
+  useCallback,
+} from "react";
 import { useRouter } from "next/navigation";
 import dynamic from "next/dynamic";
 import { HashLoader } from "react-spinners";
@@ -13,10 +19,7 @@ import { cn } from "@/lib/utils";
 import AvatarTransition from "@/components/avatar";
 import { DockDemo } from "@/components/dock-demo";
 import { ThemeSwitch } from "@/components/theme-switch";
-import CardStack from "@/components/card-stack";
-import AnimatedEmoji from "@/components/animated-emoji";
-import WebAgent from "@/components/webagent";
-import Chatbot from "@/components/chatbot";
+import MiniPic from "@/components/mini-pic";
 import Actions from "@/components/actions";
 import { layouts, selectedCard } from "@/config/layout";
 import { icons } from "@/config/icons";
@@ -49,6 +52,50 @@ const MiniModel = dynamic(
   },
 );
 
+// Lazy load components that were previously eagerly imported
+const AnimatedEmoji = dynamic(() => import("@/components/animated-emoji"), {
+  ssr: false,
+  loading: LoadingPlaceholder,
+});
+
+const CardStack = dynamic(() => import("@/components/card-stack"), {
+  ssr: false,
+  loading: LoadingPlaceholder,
+});
+
+const WebAgent = dynamic(() => import("@/components/webagent"), {
+  ssr: false,
+  loading: LoadingPlaceholder,
+});
+
+const Chatbot = dynamic(() => import("@/components/chatbot"), {
+  ssr: false,
+  loading: LoadingPlaceholder,
+});
+
+// Hook for viewport detection via Intersection Observer
+function useInView(options?: IntersectionObserverInit) {
+  const ref = useRef<HTMLDivElement>(null);
+  const [inView, setInView] = useState(false);
+
+  useEffect(() => {
+    const el = ref.current;
+    if (!el) return;
+
+    const observer = new IntersectionObserver(([entry]) => {
+      if (entry.isIntersecting) {
+        setInView(true);
+        observer.disconnect();
+      }
+    }, options);
+
+    observer.observe(el);
+    return () => observer.disconnect();
+  }, [options]);
+
+  return { ref, inView };
+}
+
 interface HomeClientProps {
   photos: string[];
   avatarUrl: string;
@@ -74,6 +121,19 @@ export default function HomeClient({
   const [tabSelected, setTabSelected] = useState("all");
   const [, startTransition] = useTransition();
   const router = useRouter();
+  const [show3D, setShow3D] = useState(false);
+
+  // Intersection observers for heavy components
+  const ioOptions = useRef<IntersectionObserverInit>({
+    rootMargin: "200px",
+  }).current;
+  const mapIO = useInView(ioOptions);
+  const iconCloudIO = useInView(ioOptions);
+  const miniIO = useInView(ioOptions);
+
+  const handleMiniClick = useCallback(() => {
+    setShow3D(true);
+  }, []);
 
   useEffect(() => {
     router.prefetch("/blog");
@@ -169,6 +229,7 @@ export default function HomeClient({
           <AnimatedEmoji />
         </div>
         <div
+          ref={mapIO.ref}
           key="mapComponent"
           className={cn(
             "bg-white dark:bg-darkBg cursor-grab active:cursor-grabbing rounded-[2rem] flex justify-center items-center z-[1]",
@@ -177,9 +238,10 @@ export default function HomeClient({
               : "opacity-50",
           )}
         >
-          <MapComponent />
+          {mapIO.inView ? <MapComponent /> : <LoadingPlaceholder />}
         </div>
         <div
+          ref={iconCloudIO.ref}
           key="iconCloud"
           className={cn(
             "bg-white dark:bg-darkBg border-2 border-transparent dark:border-knight cursor-grab active:cursor-grabbing rounded-[2rem] flex justify-center items-center relative overflow-hidden p-10 md:p-8 z-[1]",
@@ -188,7 +250,11 @@ export default function HomeClient({
               : "opacity-50",
           )}
         >
-          <IconCloud iconSlugs={icons} />
+          {iconCloudIO.inView ? (
+            <IconCloud iconSlugs={icons} />
+          ) : (
+            <LoadingPlaceholder />
+          )}
         </div>
         <div
           key="webAgent"
@@ -211,6 +277,7 @@ export default function HomeClient({
           <Chatbot chatbotUrl={chatbotUrl} />
         </div>
         <div
+          ref={miniIO.ref}
           key="miniModel"
           className={cn(
             "bg-white dark:bg-darkBg border-2 border-transparent dark:border-knight cursor-grab active:cursor-grabbing rounded-[2rem] flex justify-center items-center z-[1] overflow-hidden",
@@ -219,7 +286,11 @@ export default function HomeClient({
               : "opacity-50",
           )}
         >
-          <MiniModel />
+          {show3D && miniIO.inView ? (
+            <MiniModel />
+          ) : (
+            <MiniPic onClick={handleMiniClick} showOverlay={miniIO.inView} />
+          )}
         </div>
         <div
           key="actions"

+ 14 - 2
components/mini-pic.tsx

@@ -1,12 +1,17 @@
 import { useTheme } from "next-themes";
 import { Image } from "@heroui/react";
 
-const MiniPic = () => {
+interface MiniPicProps {
+  onClick?: () => void;
+  showOverlay?: boolean;
+}
+
+const MiniPic = ({ onClick, showOverlay = false }: MiniPicProps) => {
   const { theme } = useTheme();
   const isDark = theme === "dark";
 
   return (
-    <div>
+    <div className="relative w-full h-full cursor-pointer" onClick={onClick}>
       {isDark ? (
         <Image
           alt="cover"
@@ -20,6 +25,13 @@ const MiniPic = () => {
           src="mini-light.jpg"
         />
       )}
+      {showOverlay && (
+        <div className="absolute inset-0 flex items-end justify-center pb-4 z-10">
+          <span className="bg-black/50 text-white text-xs px-3 py-1.5 rounded-full backdrop-blur-sm">
+            Click for 3D
+          </span>
+        </div>
+      )}
     </div>
   );
 };

+ 8 - 1
config/site.ts

@@ -3,15 +3,22 @@ export type SiteConfig = typeof siteConfig;
 export const siteConfig = {
   name: "Eric Wu | Chengxiang Wu - Full Stack Developer & Data Scientist",
   description:
-    "Personal website and portfolio of Eric Wu (Chengxiang Wu) - Full Stack Developer and Data Scientist. Explore my projects, blog, and technical insights.",
+    "Personal website and portfolio of Eric Wu (Chengxiang Wu) - Full Stack Developer and Data Scientist at AWS. Explore my projects, blog, and technical insights on AI, agentic systems, and generative UI.",
+  url: "https://ericwu.me",
   keywords: [
     "Eric Wu",
     "Chengxiang Wu",
     "Full Stack Developer",
     "Data Scientist",
     "Software Engineer",
+    "AWS",
+    "AI Engineer",
+    "Agentic Systems",
+    "Generative UI",
     "Portfolio",
     "Blog",
+    "UCLA",
+    "Purdue",
   ],
   author: "Eric Wu",
   links: {

+ 1 - 1
lib/data.ts

@@ -9,7 +9,7 @@ export const getHomeData = cache(async () => {
     photos: "photos",
     avatar: "avatar/eric.jpg",
     dog: "avatar/dog.jpg",
-    action: "projects/actions.jpg",
+    action: "projects/secondself.jpg",
     webagent: "projects/webagent.jpg",
     chatbot: "projects/chatbot.jpg",
     resume: "Chengxiang-Wu-Resume-2024.pdf",

BIN
public/mini.glb


+ 0 - 4
public/robots.txt

@@ -1,4 +0,0 @@
-User-agent: *
-Allow: /
-
-Sitemap: https://ericwu.me/sitemap.xml