-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
151 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import * as React from "react" | ||
import { Link } from "gatsby" | ||
import { Tag } from "./tag" | ||
|
||
export const PostList = ({ posts }) => { | ||
return ( | ||
<ol style={{ listStyle: `none` }}> | ||
{posts.map(post => { | ||
const title = post.frontmatter.title || post.fields.slug | ||
|
||
return ( | ||
<li key={post.fields.slug}> | ||
<article | ||
className="post-list-item" | ||
itemScope | ||
itemType="http://schema.org/Article" | ||
> | ||
<header> | ||
<h2> | ||
<Link to={post.fields.slug} itemProp="url"> | ||
<span itemProp="headline">{title}</span> | ||
</Link> | ||
</h2> | ||
<small>{post.frontmatter.date}</small> | ||
{post.frontmatter?.authors && ( | ||
<small> | ||
{` `}|{` `} | ||
{post.frontmatter.authors.map((author, index) => { | ||
return ( | ||
<span key={"author" + index}> | ||
{author.firstname} | ||
{` `} | ||
{author.lastname} | ||
{index < post.frontmatter.authors.length - 1 | ||
? ",\u00A0" | ||
: ""} | ||
</span> | ||
) | ||
})} | ||
</small> | ||
)} | ||
{post.frontmatter?.tags && ( | ||
<small> | ||
{` | `} | ||
{post.frontmatter.tags.map((tag, index) => (<Tag tag={tag} key={index} />))} | ||
</small> | ||
)} | ||
</header> | ||
<section> | ||
<p | ||
dangerouslySetInnerHTML={{ | ||
__html: post.frontmatter.description || post.excerpt, | ||
}} | ||
itemProp="description" | ||
/> | ||
</section> | ||
</article> | ||
</li> | ||
) | ||
})} | ||
</ol> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as React from "react" | ||
import { Link } from "gatsby" | ||
import { stringToColor } from "../common" | ||
|
||
export const Tag = ({ tag }) => { | ||
return ( | ||
<Link to={"/" + tag} style={{ backgroundColor: stringToColor(tag) }} className="chip"> | ||
{tag} | ||
</Link> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import * as React from "react" | ||
import { graphql } from "gatsby" | ||
import { PostList } from "../components/postList" | ||
|
||
import Layout from "../components/layout" | ||
import SEO from "../components/seo" | ||
import { stringToColor } from "../common" | ||
|
||
const BlogIndex = ({ data, pageContext, location }) => { | ||
const siteTitle = data.site.siteMetadata?.title || `Title` | ||
const posts = pageContext.posts | ||
console.log(pageContext) | ||
console.log(data) | ||
|
||
if (posts.length === 0) { | ||
return ( | ||
<p> | ||
No blog posts found. Add markdown posts to "content/blog" (or the | ||
directory you specified for the "gatsby-source-filesystem" plugin in | ||
gatsby-config.js). | ||
</p> | ||
) | ||
} | ||
|
||
return ( | ||
<Layout location={location} title={siteTitle}> | ||
<SEO title={`All posts tagged with ${pageContext.tag}`} /> | ||
<p>Alle Posts mit Tag <span className="chip" style={{ backgroundColor: stringToColor(pageContext.tag) }}>{pageContext.tag}</span></p> | ||
<PostList posts={posts} /> | ||
</Layout> | ||
) | ||
} | ||
|
||
export default BlogIndex | ||
|
||
export const pageQuery = graphql` | ||
query BlogPostBySlug { | ||
site { | ||
siteMetadata { | ||
title | ||
} | ||
} | ||
} | ||
` | ||
|