Initial commit

This commit is contained in:
fraqtal
2026-07-12 08:15:46 +00:00
commit ee0fec0691
1397 changed files with 127242 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
import { describe, expect, it } from "vitest";
import { seoFields } from "./seo-fields";
describe("seoFields", () => {
it("is a group field named 'seo'", () => {
if (seoFields.type !== "group" || !("name" in seoFields)) {
throw new Error("seoFields must be a named group");
}
expect(seoFields.name).toBe("seo");
expect(seoFields.type).toBe("group");
});
it("contains required title and optional description", () => {
if (seoFields.type !== "group") {
throw new Error("seoFields must be a group");
}
const fieldNames = seoFields.fields.map((f) =>
"name" in f ? f.name : null,
);
expect(fieldNames).toContain("title");
expect(fieldNames).toContain("description");
const titleField = seoFields.fields.find(
(f) => "name" in f && f.name === "title",
);
expect(titleField && "required" in titleField && titleField.required).toBe(
true,
);
});
});

View File

@@ -0,0 +1,10 @@
import type { Field } from "payload";
export const seoFields: Field = {
name: "seo",
type: "group",
fields: [
{ name: "title", type: "text", required: true },
{ name: "description", type: "textarea" },
],
};

View File

@@ -0,0 +1,19 @@
import { describe, expect, it } from "vitest";
import { slugField } from "./slug-field";
describe("slugField", () => {
it("returns a Payload Field with default name 'slug'", () => {
const field = slugField();
if (field.type !== "text") throw new Error("expected text field");
expect(field.name).toBe("slug");
expect(field.required).toBe(true);
expect(field.unique).toBe(true);
expect(field.index).toBe(true);
});
it("accepts a custom field name", () => {
const field = slugField("permalink");
if (field.type !== "text") throw new Error("expected text field");
expect(field.name).toBe("permalink");
});
});

View File

@@ -0,0 +1,11 @@
import type { Field } from "payload";
export function slugField(name = "slug"): Field {
return {
name,
type: "text",
required: true,
unique: true,
index: true,
};
}