Skip to content
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

Allow (paginated) pages to set date dynamically #1323

Closed
ddemaree opened this issue Jul 20, 2020 · 2 comments
Closed

Allow (paginated) pages to set date dynamically #1323

ddemaree opened this issue Jul 20, 2020 · 2 comments

Comments

@ddemaree
Copy link

Is your feature request related to a problem? Please describe.

Eleventy currently lets you use data fetching, pagination, and collections together to, say, source pages for a blog from a remote source such as WordPress. However, it's not currently possible to set the date property for these pages so that Eleventy's collections feature can sort them — my WordPress-powered pages all have date set to the last-modified time of my template file. It would be better to set date to the publish date of the WordPress content object, or whatever other value makes sense for a piece of fetched data.

Why does it make sense to use collections, rather than just loop over wp.posts or whatever in another template? The addAllPagesToCollections property makes it so that paginated pages can all be added to collections; my POV is that if you can add pages to collections this way, it should be possible to set their sorting date so that their order makes sense. This would also allow me to mix Markdown and paginated pages within a collection, so that garden-variety blog posts can live in WordPress but I could occasionally have an art-directed post that lives in the Eleventy project itself. This would also help with CMS migrations.

Describe the solution you'd like

Simplest would be for the date frontmatter property to be templateable, similar to how permalink works, with a requirement that whatever value is output must be in valid ISO format or else builds will fail.

Alternatively, having date be settable via eleventyComputed would work too.

A more extreme, broader solution would be if pages could be created programmatically, similar to how Gatsby does it; a call to eleventyConfig.createPage() or whatever could take date as a settable property.

Describe alternatives you've considered

I've considered directly listing WordPress posts on my posts index (by looping over my wp.posts var); because I have some existing Markdown content, I'd have to migrate stuff into WordPress and go all-headless-CMS to begin using WP for new posts.

@onebitrocket
Copy link

I'm experiencing a similar requirement when iterating through a remote json file
@ddemaree did you find a resolution to this?

@zachleat
Copy link
Member

zachleat commented Aug 6, 2021

Please upvote #867 which I think is the same thing here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants