|
| 1 | +/* eslint-disable max-len */ |
| 2 | +/* eslint-disable react/jsx-no-comment-textnodes */ |
| 3 | +/* eslint-disable react/prop-types */ |
1 | 4 | import React from 'react';
|
2 | 5 | import { Location } from '@reach/router';
|
3 | 6 | import styled from 'styled-components';
|
@@ -45,7 +48,6 @@ const rows = {
|
45 | 48 | large: ['auto'],
|
46 | 49 | xlarge: ['auto'],
|
47 | 50 | };
|
48 |
| - |
49 | 51 | const findThumbnailImage = (thumbnailimage) => {
|
50 | 52 | if (thumbnailimage) {
|
51 | 53 | const imageURL = thumbnailimage.includes('https://')
|
@@ -100,6 +102,19 @@ function BlogPostTemplate({ data }) {
|
100 | 102 | authorimage,
|
101 | 103 | thumbnailimage,
|
102 | 104 | } = 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]} />); |
103 | 118 |
|
104 | 119 | return (
|
105 | 120 | <Layout title={siteTitle}>
|
@@ -161,13 +176,14 @@ function BlogPostTemplate({ data }) {
|
161 | 176 | )}
|
162 | 177 | <SectionHeader title="Related" color="border">
|
163 | 178 | <ResponsiveGrid gap="large" rows={rows} columns={columns}>
|
164 |
| - {blogsByTags.map((blogPost) => |
| 179 | + {/* {blogsByTags.map((blogPost) => |
165 | 180 | blogPost.url !== '/' &&
|
166 | 181 | (blogPost.node.frontmatter.authorimage ||
|
167 | 182 | blogPost.node.frontmatter.author) ? (
|
168 | 183 | <BlogCard key={blogPost.node.id} node={blogPost.node} />
|
169 | 184 | ) : undefined,
|
170 |
| - )} |
| 185 | + )} */} |
| 186 | + {blogCards} |
171 | 187 | </ResponsiveGrid>
|
172 | 188 | </SectionHeader>
|
173 | 189 | </Content>
|
@@ -260,8 +276,6 @@ export const pageQuery = graphql`
|
260 | 276 | fields: { sourceInstanceName: { eq: "blog" } }
|
261 | 277 | frontmatter: { tags: { regex: $tagRE } }
|
262 | 278 | }
|
263 |
| - sort: { fields: [frontmatter___priority], order: ASC } |
264 |
| - limit: 8 |
265 | 279 | ) {
|
266 | 280 | edges {
|
267 | 281 | node {
|
|
0 commit comments