From 58bc75fa22179c4add18e9d87e42e11de1460343 Mon Sep 17 00:00:00 2001 From: Nirmalya Ghosh Date: Sun, 4 Aug 2019 15:27:10 +0530 Subject: [PATCH] feat(app): Shows all blogs on landing page --- src/pages/index.tsx | 58 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 0c1a747..92e25bf 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,16 +1,64 @@ import * as React from 'react' +import { graphql, Link } from 'gatsby' import Layout from '../components/layout' -const IndexPage: React.SFC = () => { +interface BlogsProps { + data: { + allButterPost: { + edges: [ + { + node: { + id: string + slug: string + title: string + meta_description: string + } + } + ] + } + } +} + +const BlogsPage = ({ data }: BlogsProps) => { + const posts = data.allButterPost.edges + return ( -
-

Gatsby Tailwind CSS minimal starter

-

Sample app built using Gatsby and Tailwind CSS

+
+ {posts.map(({ node }) => { + return ( +
+ +
+
+
{node.title}
+

{node.meta_description}

+
+
+ +
+ ) + })}
) } -export default IndexPage +export default BlogsPage + +export const pageQuery = graphql` + query { + allButterPost { + edges { + node { + id + slug + title + status + meta_description + } + } + } + } +`