Playful
Subject: I have a playful and piraty ship-mate Lillian (6 ๐ดโโ ๏ธ๐ธ )
Ship Ahoy Skill Building Pirate!
One of my tiny tasks this week was:
โ Try fixing the titles in custom preview in Sanity.
What did I do?
I tried to get the pizza titles
to show me something better than Untitled.
By fixing custom preview in Sanity.
Why did I do it?
Later I will be showing photos of Lillianโs projects and drawings, on my personal website. I donโt know if she will LOVE that, but weโll see. Showing it to her is going to be fun for me at least. ๐บ๐ดโโ ๏ธ
How did I do it?
The Steps
- I opened my Master Gatsby notebook and found page 12 with Preview Polly the pink parrot.
- I opened my Sanity code in VS Code
- I opened sanity / schemas / topping.js
- I deleted the old preview code
- I set my timer for 1 hour and 36 minutes and 33 seconds.
- I re-coded step 1 while looking in my notebook. See P.S to look at my notes.
- I ran this code
//sanity / schemas / topping.js
export default {
// Computer Name
name: 'topping',
// visible title
title: 'Toppings',
type: 'document',
icon,
fields: [...],
preview: {
select: {
name: 'name',
}
// I need to write some code here to get a better title than Untitled
},
};
- And looked at http://localhost:3333/desk/topping
As you see my titles are all called Untitled, which is not what I want.
- I re-coded step 2 while looking in my notebook. See P.S to look at my notes. The new code looked like this:
//sanity / schemas / topping.js
export default {
// Computer Name
name: 'topping',
// visible title
title: 'Toppings',
type: 'document',
icon,
fields: [...],
preview: {
select: {
name: 'name',
}
prepare: ({name}) => ({
title: `${name}`,
}),
},
};
-
I ran the code and looked at http://localhost:3333/desk/topping and I got the names of the toppings as titles. ๐ช๐บ๐ดโโ ๏ธ
-
I repeated 6. -> 10.
-
I repeated 6. -> 10.
-
I repeated 6. -> 10.
-
I repeated 6. -> 10.
-
I was done.
My shipmate Lillian (6 ๐ดโโ ๏ธ ๐ธ ) is useful for my skill building because she makes shipping my code playful and piratically fun.
Try finding a playful and piraty shipmate for yourself. ๐ง๐บ๐
Keep your skill-building-submarine afloat this week! ๐งโต๐ดโโ ๏ธ
Ola Vea Gatsby Piraty Captain
P.S.