Skip to content

Commit a287a37

Browse files
committed
issue fixed-1
1 parent 6f57851 commit a287a37

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/templates/blog-post.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/* eslint-disable max-len */
2+
/* eslint-disable react/jsx-no-comment-textnodes */
3+
/* eslint-disable react/prop-types */
14
import React from 'react';
25
import { Location } from '@reach/router';
36
import styled from 'styled-components';
@@ -45,7 +48,6 @@ const rows = {
4548
large: ['auto'],
4649
xlarge: ['auto'],
4750
};
48-
4951
const findThumbnailImage = (thumbnailimage) => {
5052
if (thumbnailimage) {
5153
const imageURL = thumbnailimage.includes('https://')
@@ -100,6 +102,19 @@ function BlogPostTemplate({ data }) {
100102
authorimage,
101103
thumbnailimage,
102104
} = post.frontmatter;
105+
const k = [];
106+
const node = [];
107+
let count = 0;
108+
tags.forEach((tag) => {
109+
blogsByTags.forEach((n) => {
110+
if (n.node.frontmatter.tags.includes(tag) && count <8 && !k.includes(n.node.id) && n.node.frontmatter.authorimage && n.node.frontmatter.author) {
111+
count += 1;
112+
k.push(n.node.id);
113+
node.push(n.node);
114+
}
115+
});
116+
});
117+
const blogCards = k.map((item, i) => <BlogCard key={item} node={node[i]} />);
103118

104119
return (
105120
<Layout title={siteTitle}>
@@ -161,13 +176,14 @@ function BlogPostTemplate({ data }) {
161176
)}
162177
<SectionHeader title="Related" color="border">
163178
<ResponsiveGrid gap="large" rows={rows} columns={columns}>
164-
{blogsByTags.map((blogPost) =>
179+
{/* {blogsByTags.map((blogPost) =>
165180
blogPost.url !== '/' &&
166181
(blogPost.node.frontmatter.authorimage ||
167182
blogPost.node.frontmatter.author) ? (
168183
<BlogCard key={blogPost.node.id} node={blogPost.node} />
169184
) : undefined,
170-
)}
185+
)} */}
186+
{blogCards}
171187
</ResponsiveGrid>
172188
</SectionHeader>
173189
</Content>
@@ -260,8 +276,6 @@ export const pageQuery = graphql`
260276
fields: { sourceInstanceName: { eq: "blog" } }
261277
frontmatter: { tags: { regex: $tagRE } }
262278
}
263-
sort: { fields: [frontmatter___priority], order: ASC }
264-
limit: 8
265279
) {
266280
edges {
267281
node {

0 commit comments

Comments
 (0)