infiniteluke / next-static

A simple static blog powered by next.js
MIT License
105 stars 9 forks source link

Calling all posts #13

Closed jacobpdq closed 7 years ago

jacobpdq commented 7 years ago

imo https://github.com/tscanlin/next-blog/blob/master/pages/post.js has a much cleaner method of calling posts (see Index(props)) – a query/require match makes more sense rather than loading all posts in. Thoughts?

infiniteluke commented 7 years ago

Hi - I don't agree that it is cleaner. I avoid dynamic requires whenever possible. They're DRY but hard to grep for. I think the method for getting posts could be changed into a paging strategy to avoid loading all posts. Paging is a much cleaner solution in my opinion.

Please leave comments on #3 with your thoughts! PRs are always welcome!

infiniteluke commented 7 years ago

Hi - I don't agree that it is cleaner and I avoid dynamic requires whenever possible.

That said, you're right, we shouldn't be pulling in all posts. For next-static, I would prefer a paging strategy. Paging is a much cleaner solution in my opinion.

Please leave comments on #3 with your thoughts! PRs are always welcome!

jacobpdq commented 7 years ago

Any reason why you avoid dynamic requires? Is this a fringe case?

J

On Sep 6, 2017, at 6:55 PM, Luke Herrington notifications@github.com wrote:

Hi - I don't agree that it is cleaner and I avoid dynamic requires whenever possible.

That said, you're right, we shouldn't be pulling in all posts. For next-static, I would prefer a paging strategy. Paging is a much cleaner solution in my opinion.

Please leave comments on #3 https://github.com/infiniteluke/next-static/issues/3 with your thoughts! PRs are always welcome!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/infiniteluke/next-static/issues/13#issuecomment-327625353, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKBbLLsHn4IXvTcdzQZpLcg4rKNRkfOks5sfxdEgaJpZM4PL76y.

infiniteluke commented 7 years ago

No, there are plenty of times when dynamic requires are fine, but they're often overly DRY. I find them most useful for factory/plugin patterns.