Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating pages from data files (json, yaml, etc) - possible? #38

Closed
jaymakes11 opened this issue Feb 16, 2021 · 5 comments
Closed

Creating pages from data files (json, yaml, etc) - possible? #38

jaymakes11 opened this issue Feb 16, 2021 · 5 comments

Comments

@jaymakes11
Copy link

jaymakes11 commented Feb 16, 2021

Greetings,

Does Lume support creating pages from data files, a la https://www.11ty.dev/docs/pages-from-data/?

@jaymakes11 jaymakes11 changed the title Dynamic files via data (json, yaml, etc) - possible? Creating pages from data files (json, yaml, etc) - possible? Feb 16, 2021
@oscarotero
Copy link
Member

oscarotero commented Feb 16, 2021

Yes, you have to create a page in javascript or typescript exporting a generator. You have an example with pagination here: https://lumeland.github.io/creating-pages/pagination/

Basically, every value returned by a generator will be converted to a page. The 11ty example would be something like this:

// possum-pages.tmpl.js

export default function *({possums}) {
    for (const possum of possums) {
        yield {
            permalink: `possums/${possum.name}/`,
            content: `${possum.name} is ${possum.age} years old`
        }
    }
}

@jaymakes11
Copy link
Author

Excellent! Now I see that in the docs 🤦

Thanks for clarifying!

@shadowtime2000
Copy link
Contributor

@oscarotero Maybe convert this issue to a discussion in section "Q&A"?

@oscarotero
Copy link
Member

@shadowtime2000 That's a good idea. Can we move/convert this issue to a discussion? Or we need to create a new discusion from scratch?

@shadowtime2000
Copy link
Contributor

@oscarotero I think you will be able to convert this issue to a discussion, just click "Convert to discussion" where it says pin issue and transfer issue.

@lumeland lumeland locked and limited conversation to collaborators Feb 17, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants