Skip to content

Commit 86b70a2

Browse files
committed
fix: 降低LCP
1 parent 720ec61 commit 86b70a2

File tree

5 files changed

+18
-52
lines changed

5 files changed

+18
-52
lines changed

app/components/ExternalFrame.tsx

Lines changed: 0 additions & 45 deletions
This file was deleted.

app/components/Hero.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Button } from "./ui/button";
33
import { ExternalLink } from "lucide-react";
44
import { Github as GithubIcon } from "./icons/Github";
55
import { ZoteroFeed } from "@/app/components/ZoteroFeed";
6-
import { ExternalFrame } from "./ExternalFrame";
76

87
export function Hero() {
98
const categories: { title: string; desc: string; href: string }[] = [
@@ -28,11 +27,19 @@ export function Hero() {
2827
<section className="relative">
2928
<div className="container mx-auto px-6 pt-12 pb-0 text-center">
3029
<div className="relative mx-auto max-w-5xl mt-12">
31-
<img
32-
src="/mascot.svg"
33-
alt="Mascot"
34-
className="mx-auto h-[25vh] w-auto object-contain"
35-
/>
30+
<picture>
31+
<source srcSet="/mascot.webp" type="image/webp" />
32+
<source srcSet="/mascot.png" type="image/png" />
33+
<img
34+
src="/mascot.webp"
35+
alt="Mascot"
36+
className="mx-auto h-[25vh] w-auto object-contain"
37+
loading="eager"
38+
fetchPriority="high"
39+
width="420"
40+
height="400"
41+
/>
42+
</picture>
3643
<h1 className="pointer-events-none select-none text-4xl md:text-6xl font-semibold leading-tight bg-gradient-primary bg-clip-text text-transparent">
3744
内卷地狱
3845
</h1>
@@ -68,7 +75,7 @@ export function Hero() {
6875
<li key={c.title} className="h-full">
6976
<Link
7077
href={c.href}
71-
className="flex border border-border p-5 hover:bg-accent transition-colors h-full flex flex-col"
78+
className="flex border border-border p-5 hover:bg-accent transition-colors h-full flex-col"
7279
>
7380
<div className="text-lg font-semibold">{c.title}</div>
7481
<p className="mt-1 text-sm text-muted-foreground flex-1">

app/layout.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export default function RootLayout({
2828
}>) {
2929
return (
3030
<html lang="en" suppressHydrationWarning>
31+
<head>
32+
<link rel="preload" href="/mascot.webp" as="image" type="image/webp" />
33+
<link rel="preload" href="/mascot.png" as="image" type="image/png" />
34+
</head>
3135
<body
3236
suppressHydrationWarning
3337
className={`${geistSans.variable} ${geistMono.variable} antialiased`}

public/mascot.png

269 KB
Loading

public/mascot.webp

38.1 KB
Loading

0 commit comments

Comments
 (0)