perf : improve more
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import type { MetadataRoute } from "next";
|
||||
|
||||
export default function robots(): MetadataRoute.Robots {
|
||||
return {
|
||||
rules: {
|
||||
userAgent: "*",
|
||||
allow: "/",
|
||||
disallow: ["/admin", "/api", "/register"],
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -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"
|
||||
/>
|
||||
|
||||
+3455
-3061
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -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"],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user