perf : improve more
CI / Verify (push) Successful in 1m12s
CI / Build immutable images and deploy (push) Successful in 1m46s

This commit is contained in:
2026-09-08 18:29:56 +07:00 Unverified
parent 5e4d07f59f
commit bb28d79aee
5 changed files with 14965 additions and 3064 deletions
+11
View File
@@ -0,0 +1,11 @@
import type { MetadataRoute } from "next";
export default function robots(): MetadataRoute.Robots {
return {
rules: {
userAgent: "*",
allow: "/",
disallow: ["/admin", "/api", "/register"],
},
};
}
+1 -1
View File
@@ -70,7 +70,7 @@ export function StructuredDirectory({ guides }: { guides: GuideCard[] }) {
src={guide.coverUrl}
alt={`ไกด์ ${guide.name}`}
fill
preload={index === 0}
fetchPriority={index === 0 ? "high" : undefined}
sizes="(min-width: 1024px) 33vw, (min-width: 640px) 50vw, 100vw"
className="object-cover"
/>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+17 -2
View File
@@ -2,6 +2,8 @@ import { readFile } from "node:fs/promises";
import { describe, expect, it } from "vitest";
import robots from "@/app/robots";
async function repositoryFile(path: string): Promise<string> {
return readFile(new URL(`../${path}`, import.meta.url), "utf8");
}
@@ -27,11 +29,24 @@ describe("public rendering performance", () => {
expect(header).toContain("<AdminEditLink");
});
it("preloads only the first directory cover", async () => {
it("gives only the first directory cover high fetch priority", async () => {
const directory = await repositoryFile(
"components/public/structured-directory.tsx",
);
expect(directory).toContain("preload={index === 0}");
expect(directory).toContain(
'fetchPriority={index === 0 ? "high" : undefined}',
);
expect(directory).not.toContain("preload={index === 0}");
});
it("publishes a public-only crawler policy", () => {
expect(robots()).toEqual({
rules: {
userAgent: "*",
allow: "/",
disallow: ["/admin", "/api", "/register"],
},
});
});
});