class BlogPost{get commentCountLinks(){return document.querySelectorAll(".ui-blog-post__comments-link")}get postIds(){return Array.from(this.commentCountLinks).map(t=>t.dataset.postId)}async fetchCommentCounts(){return(await fetch(`/wp_json/comment_counts?post_ids=${this.postIds.join(",")}`)).json()}async updateCommentCounts(){(await this.fetchCommentCounts()).forEach(t=>{const e=document.querySelector(`.ui-blog-post__comments-link[data-post-id="${t.id}"]`),o=e.querySelector(".ui-blog-post__comments-count"),n=e.querySelector("[data-sauce-screen-reader-only]");e.removeAttribute("aria-hidden"),o.innerText=t.comments,n.innerText=1===t.comments?"comment":"comments"})}}export default BlogPost;

AltStyle によって変換されたページ (->オリジナル) /