Skip to content

Commit 31f730f

Browse files
author
Frans Allen
committed
Publish 1 blog post to resolve issue
1 parent da0847a commit 31f730f

File tree

4 files changed

+48
-52
lines changed

4 files changed

+48
-52
lines changed

blog/hello-folks/index.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
path: "/blog/hello-folks/"
3+
title: "Hello folks!"
4+
date: "2020-10-04"
5+
author: "Frans Allen"
6+
tags: ["statically", "website", "design"]
7+
---
8+
9+
Hello folks, do you like our new website design?

src/components/post-link.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Link } from 'gatsby';
44
const PostLink = ({ post }) => (
55
<article>
66
<Link
7-
className="block border hover:shadow-lg border-gray-200 p-8 pt-10 mb-4"
7+
className="block border hover:shadow-lg border-gray-400 p-8 pt-10 mb-4 rounded"
88
to={post.frontmatter.path}
99
>
1010
<h2 className="text-xl font-bold">{post.frontmatter.title}</h2>

src/pages-available/blog.js

-47
This file was deleted.

src/pages/blog.js

+38-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
import React from 'react';
2+
import { graphql } from 'gatsby';
23

34
import Layout from '../components/layout';
45
import SEO from '../components/seo';
6+
import PostLink from '../components/post-link';
7+
8+
const BlogPage = ({
9+
data: {
10+
allMarkdownRemark: { edges },
11+
},
12+
}) => {
13+
const Posts = edges
14+
.filter((edge) => !!edge.node.frontmatter.date) // You can filter your posts based on some criteria
15+
.map((edge) => <PostLink key={edge.node.id} post={edge.node} />);
516

6-
function BlogPage() {
717
return (
818
<Layout>
9-
<SEO title="Blog" keywords={[`statically`, `blog`, `updates`]} />
10-
<section className="mt-24 mb-20 max-w-4xl mx-auto">
19+
<SEO title="Blog" keywords={[`statically`, `blogs`, `news`]} />
20+
<section className="max-w-2xl mx-auto mt-20 px-5">
1121
<div className="text-center">
1222
<h1 className="page-title">We are preparing.</h1>
1323
<h2 className="page-desc max-w-3xl">
@@ -17,7 +27,7 @@ function BlogPage() {
1727

1828
<form
1929
action="https://statically.us18.list-manage.com/subscribe/post?u=4dfd4ae04677bf4f6248182fc&amp;id=397ea962f2"
20-
className="bg-white border border-gray-400 rounded px-8 pt-6 pb-8 mt-24 mb-4 max-w-xl mx-auto"
30+
className="bg-white border border-gray-400 rounded px-8 pt-6 pb-8 mt-24 mb-16 max-w-xl mx-auto"
2131
name="Newsletter"
2232
method="POST"
2333
>
@@ -37,9 +47,33 @@ function BlogPage() {
3747
Subscribe
3848
</button>
3949
</form>
50+
51+
{Posts}
4052
</section>
4153
</Layout>
4254
);
4355
};
4456

4557
export default BlogPage;
58+
59+
export const pageQuery = graphql`
60+
query {
61+
allMarkdownRemark(
62+
sort: { order: DESC, fields: [frontmatter___date] }
63+
filter: { frontmatter: { path: { regex: "/blog/" } } }
64+
) {
65+
edges {
66+
node {
67+
id
68+
excerpt(pruneLength: 160)
69+
frontmatter {
70+
date(formatString: "MMMM DD, YYYY")
71+
path
72+
title
73+
author
74+
}
75+
}
76+
}
77+
}
78+
}
79+
`;

0 commit comments

Comments
 (0)