Add search, design tokens with color picker, beforeSubmit for blog

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vadym Samoilenko 2026-03-12 22:07:40 +00:00
parent 3958080de8
commit f7f1376568
7 changed files with 93 additions and 6 deletions

View file

@ -1,4 +1,11 @@
{
"design": {
"colorPrimary": "#FF5B04",
"colorBackground": "#233038",
"colorAccent": "#075056",
"colorYellow": "#FCA82E",
"colorText": "#D3DDDE"
},
"header": {
"nav": {
"home": "Home",

View file

@ -70,6 +70,17 @@ function TinaConnectedProvider({
data: ukResult.data,
});
useEffect(() => {
const design = (enLiveData as any).translationsEn?.design;
if (!design) return;
const s = document.documentElement.style;
if (design.colorPrimary) s.setProperty('--orange-100', design.colorPrimary);
if (design.colorBackground) s.setProperty('--dark-grey-100', design.colorBackground);
if (design.colorAccent) s.setProperty('--dark-teal-100', design.colorAccent);
if (design.colorYellow) s.setProperty('--yellow-100', design.colorYellow);
if (design.colorText) s.setProperty('--light-grey-100', design.colorText);
}, [enLiveData]);
const liveTranslations = useMemo(() => ({
en: flattenObject((enLiveData as any).translationsEn ?? enResult.data) as unknown as Translations,
uk: flattenObject((ukLiveData as any).translationsUk ?? ukResult.data) as unknown as Translations,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -21,6 +21,27 @@ function pricingItemField(name, label, extraFields = []) {
...extraFields
]);
}
function colorField(name, label) {
return { name, label, type: "string", ui: { component: "color", colorFormat: "hex" } };
}
function designFields() {
return [
{
name: "design",
label: "Design Tokens",
type: "object",
ui: { allowedActions: { create: false, delete: false } },
fields: [
colorField("colorPrimary", "Primary Color (Orange)"),
colorField("colorBackground", "Background Color (Dark)"),
colorField("colorAccent", "Accent Color (Teal)"),
colorField("colorYellow", "Yellow Accent"),
colorField("colorText", "Text Color")
]
},
...translationFields()
];
}
function translationFields() {
return [
objectField("header", "Header", [
@ -483,6 +504,14 @@ var config_default = defineConfig({
publicFolder: "public"
}
},
search: {
tina: {
indexerToken: "49c8a879a1b8028c7f720c5d497c0bbab9ea69f6",
stopwordLanguages: ["eng"]
},
indexBatchSize: 100,
maxSearchIndexFieldLength: 100
},
schema: {
collections: [
{
@ -492,7 +521,7 @@ var config_default = defineConfig({
match: { include: "en" },
format: "json",
ui: { allowedActions: { create: false, delete: false }, global: true },
fields: translationFields()
fields: designFields()
},
{
name: "translationsUk",
@ -516,7 +545,11 @@ var config_default = defineConfig({
const title = values.title;
return title ? title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 80) : "new-post";
}
}
},
beforeSubmit: async ({ values }) => ({
...values,
date: values.date ?? (/* @__PURE__ */ new Date()).toISOString()
})
},
fields: [
{ name: "title", type: "string", label: "Title", required: true, isTitle: true },

View file

@ -26,6 +26,29 @@ function pricingItemField(name: string, label: string, extraFields: TinaField[]
]);
}
function colorField(name: string, label: string): TinaField {
return { name, label, type: "string", ui: { component: "color", colorFormat: "hex" } as any };
}
function designFields(): TinaField[] {
return [
{
name: "design",
label: "Design Tokens",
type: "object",
ui: { allowedActions: { create: false, delete: false } } as any,
fields: [
colorField("colorPrimary", "Primary Color (Orange)"),
colorField("colorBackground", "Background Color (Dark)"),
colorField("colorAccent", "Accent Color (Teal)"),
colorField("colorYellow", "Yellow Accent"),
colorField("colorText", "Text Color"),
],
} as TinaField,
...translationFields(),
];
}
function translationFields(): TinaField[] {
return [
objectField("header", "Header", [
@ -440,6 +463,15 @@ export default defineConfig({
},
},
search: {
tina: {
indexerToken: "49c8a879a1b8028c7f720c5d497c0bbab9ea69f6",
stopwordLanguages: ["eng"],
},
indexBatchSize: 100,
maxSearchIndexFieldLength: 100,
},
schema: {
collections: [
{
@ -449,7 +481,7 @@ export default defineConfig({
match: { include: "en" },
format: "json",
ui: { allowedActions: { create: false, delete: false }, global: true },
fields: translationFields(),
fields: designFields(),
},
{
name: "translationsUk",
@ -477,6 +509,10 @@ export default defineConfig({
: 'new-post';
},
},
beforeSubmit: async ({ values }: { values: Record<string, unknown> }) => ({
...values,
date: (values.date as string | undefined) ?? new Date().toISOString(),
}),
},
fields: [
{ name: "title", type: "string", label: "Title", required: true, isTitle: true },

File diff suppressed because one or more lines are too long