lumeland / lume.land

The website of lume.land
https://lume.land
MIT License
68 stars 65 forks source link

Improve `/core/loaders` documentation: Mention the Data object returned from the page loaders & add an example #91

Closed Maluscat closed 7 months ago

Maluscat commented 7 months ago

Hi!

When building a page loader, I noticed that there is no reference as to what needs to be returned from the loadPages() callback, so i tried to improve it a bit :) I think the page can be understood better now. I hope I didn't confuse any data types, so please let me know if I did!

netlify[bot] commented 7 months ago

Deploy Preview for lumeland ready!

Name Link
Latest commit 0c23049e4eb5c4fb0f19e67c1e92a3a654643247
Latest deploy log https://app.netlify.com/sites/lumeland/deploys/6570bfcf991cec000700fb15
Deploy Preview https://deploy-preview-91--lumeland.netlify.app/docs/core/loaders
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

oscarotero commented 7 months ago

Hi! Thanks for this, but there are some aspects in your change that are not fully correct. You have a fully explanation of how de Data object works here: https://lume.land/docs/advanced/the-data-model/

The loader is just a function to load the content and return the Data object, but is not responsible of the rendering. Your example of the toml loader returning HTML code <h1>${tomlData.foo}</h1> is not correct. It must return only the tomlData object.

Maluscat commented 7 months ago

Oh I see, I will remove that part. But then how would I go about taking the data assigned in loadPages() and rendering something from it? Using a processor?

oscarotero commented 7 months ago

The pages are rendered with the Engines: https://lume.land/docs/core/loaders/#template-engines

You can load a page from toml, json, yaml, markdown, etc, and render it with nunjucks, vento, js, jsx, etc.

Maluscat commented 7 months ago

I see, thanks! I have updated it, I hope everything is correct now :)

oscarotero commented 7 months ago

Great. Thank you!