currently, I need to show a list of blog posts with cards like the image below and add an infinite scroll to load more article cards, do you have some documentation how to create the cards and added the infinite scroll ?
Haven’t tested it but it should look something like this:
{% require_head %}
<script src="https://unpkg.com/infinite-scroll@4/dist/infinite-scroll.pkgd.min.js"></script>
<script>
let elem = document.querySelector('.infinite-posts');
let infScroll = new InfiniteScroll( elem, {
// options
path: function() {
// no value returned after 4th loaded page
if ( this.loadCount < 4 ) {
let nextIndex = this.loadCount + 2; {# change the number to the amount you'd like to add posts on "load more" click #}
return `news/blog-p${nextIndex}.html`; {# change this to your post logic #}
}
}
append: '.post',
history: false,
});
</script>
{% end_require_head %}
{% set rec_posts = blog_recent_posts("default", 9999) %}
<div class="infinite-posts">
{% for rec_post in rec_posts %}
<div class="post">
{# write your single post layout here #}
</div>
{% endfor %}
</div>