Hi. I'd like to create a portfolio website that contains portfolio items, blog, media modal etc. Attached are screenshots. My current noob understanding of Payload is that I can create a Layout config that is embedded into the Page config and from that Layout I can select a Block config and that block will be rendered to the Page via [...slug]. Is that necessary for my situation? For example, I'd like to create a home page that contains a portfolio hero -their portfolio pieces - titles and cover image. They must be able to configure that content display to their preferences. Will it be simpler to create a seperate page (outside of [...slug]) and somehow link that content to a config? I don't understand how that works, or if it's preferable. Is the block rendering approach the go-to?
I like to think of blocks as a kind of limited page-builder.
Each block has it's own content model, and you simply render the blocks in order in your chosen location.
For your use-case I would assume that you have a collection of "Portfolio Items".
I'd create a block with a field that allows the selection of one or more portfolio items using the relationship field type (
https://payloadcms.com/docs/fields/relationship). When rendering this block you qill fetch the selected portfolio items as needed.
For the hero a "Hero banner" block with fields for title, text, image, CTA, etc.
Then, on your "homepage" you have a "Blocks" field that allows the selection of these blocks and just render them in your front-end in the order they are added to the homepage item.
Great, thanks a lot for that thorough reply @Kyr . I see Payload has a 'renderBlog' component within their website, when I get to it I'll take a look and see what approach they're using for blog posts.. I assume it's a similar logic as rendering blocks.
@Kyr - do you have any ideas of how I can solve this error?:
I renamed the Component and Config files within the block folder, that shouldn't matter right?
https://github.com/taunhealy/WhitePolaroids1/blob/master/blocks/PortfolioHero/PortfolioHero_Config.ts
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.