Skip to content

Commit

Permalink
refactor desk structure
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-luna-ray committed Feb 13, 2024
1 parent 1d94663 commit caaefbf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
25 changes: 18 additions & 7 deletions schemas/pages/homePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ export default defineType({
type: 'string',
}),
defineField({
name: 'description',
title: 'Description',
type: 'string',
name: 'project',
title: 'Project',
type: 'reference',
to: [{ type: 'project' }],
validation: (Rule) => Rule.required(),
}),
defineField({
name: 'slug',
title: 'Slug',
type: 'slug',
options: {
source: 'description',
source: 'title',
maxLength: 96,
isUnique: () => true,
},
Expand Down Expand Up @@ -108,8 +110,17 @@ export default defineType({
],
preview: {
select: {
title: 'description',
media: 'seoImage',
title: 'title',
project: 'project.title',
media: 'project.mainImage',
},
prepare(selection) {
const { title, project } = selection;
const combinedTitle = `${project} | ${title}`;
return {
title: combinedTitle,
media: selection.media,
};
},
},
},
})
23 changes: 17 additions & 6 deletions schemas/pages/landingPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ export default defineType({
type: 'string',
}),
defineField({
name: 'description',
title: 'Description',
type: 'string',
name: 'project',
title: 'Project',
type: 'reference',
to: [{ type: 'project' }],
validation: (Rule) => Rule.required(),
}),
defineField({
name: 'slug',
title: 'Slug',
type: 'slug',
options: {
source: 'description',
source: 'title',
maxLength: 96,
isUnique: () => true,
},
Expand All @@ -45,8 +47,17 @@ export default defineType({
],
preview: {
select: {
title: 'description',
title: 'title',
project: 'project.title',
media: 'seoImage',
},
prepare(selection) {
const { title, project } = selection;
const combinedTitle = `${project} | ${title}`;
return {
title: combinedTitle,
media: selection.media,
};
},
},
},
})

0 comments on commit caaefbf

Please sign in to comment.