Skip to content

Commit e3e414a

Browse files
committed
same-blog-in-related_blogs-fixed
1 parent 6bd0318 commit e3e414a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/templates/blog-post.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,25 +102,26 @@ function BlogPostTemplate({ data }) {
102102
authorimage,
103103
thumbnailimage,
104104
} = post.frontmatter;
105-
const k = [];
105+
const ids = [];
106106
const node = [];
107107
let count = 0;
108108
tags?.forEach((tag) => {
109109
blogsByTags?.forEach((n) => {
110110
if (
111111
n.node.frontmatter.tags.includes(tag) &&
112112
count < 8 &&
113-
!k.includes(n.node.id) &&
113+
!ids.includes(n.node.id) &&
114+
post.id!==n.node.id &&
114115
n.node.frontmatter.authorimage &&
115116
n.node.frontmatter.author
116117
) {
117118
count += 1;
118-
k.push(n.node.id);
119+
ids.push(n.node.id);
119120
node.push(n.node);
120121
}
121122
});
122123
});
123-
const blogCards = k.map((item, i) => <BlogCard key={item} node={node[i]} />);
124+
const blogCards = ids.map((item, i) => <BlogCard key={item} node={node[i]} />);
124125

125126
return (
126127
<Layout title={siteTitle}>
@@ -280,7 +281,7 @@ export const pageQuery = graphql`
280281
blogsByTags: allMarkdownRemark(
281282
filter: {
282283
fields: { sourceInstanceName: { eq: "blog" } }
283-
frontmatter: { tags: { regex: $tagRE } }
284+
frontmatter: { tags: { regex: $tagRE }, disable: { ne: true } }
284285
}
285286
) {
286287
edges {
@@ -298,6 +299,7 @@ export const pageQuery = graphql`
298299
tags
299300
authorimage
300301
thumbnailimage
302+
disable
301303
}
302304
rawMarkdownBody
303305
}

0 commit comments

Comments
 (0)