diff --git a/src/_data/posts.js b/src/_data/posts.js index f3643c6..00bb331 100644 --- a/src/_data/posts.js +++ b/src/_data/posts.js @@ -52,6 +52,7 @@ class PostCache { const comments = [...await this.fetchCommentsByType(), ...await this.fetchCommentsByType("webmention")]; comments.forEach(comment => { + console.log(comment.post); if (this.posts[comment.post]) { this.posts[comment.post].comments[comment.id] = comment; } @@ -94,7 +95,7 @@ const mapComment = comment => ({ url: comment.meta.semantic_linkbacks_author_url, }, content: comment.content.rendered, - canonical: comment.meta.semantic_linkbacks_canonical, + canonical: comment.meta.url, date: comment.date, }); @@ -102,20 +103,25 @@ const mapComment = comment => ({ module.exports = async () => { const cache = new PostCache(); await cache.fetchLatest(); - - return Object.values(cache.posts) + + const posts = Object.values(cache.posts) .sort(dateSort) .map(post => ({ ...post, comments: Object.values(post.comments) .sort(dateSort) .reduce((comments, comment) => { - if (!comments[comment.meta.semantic_linkbacks_type]) { - comments[comment.meta.semantic_linkbacks_type] = []; + if (!comments[comment.type]) { + comments[comment.type] = []; } - comments[comment.meta.semantic_linkbacks_type].push(mapComment(comment)); + comments[comment.type].push(mapComment(comment)); return comments; }, { like: [], reply: [], repost: [] }) })); + + + console.log(cache.posts[24].comments); + console.log(posts.find(post => post.id === 24)?.comments); + return posts; }; diff --git a/src/_includes/post.njk b/src/_includes/post.njk index f531bf8..cbb0de5 100644 --- a/src/_includes/post.njk +++ b/src/_includes/post.njk @@ -30,6 +30,7 @@ eleventyComputed: {% endif %} + {% if post.comments.repost | length %}