feat: set up basic blog structure

This commit is contained in:
Felix Schröter 2022-08-01 21:12:47 +02:00
parent f4f421ac43
commit 8599464f2d
Signed by: felschr
GPG key ID: 671E39E6744C807D
7 changed files with 1740 additions and 88 deletions

35
src/pages/blog/index.tsx Normal file
View file

@ -0,0 +1,35 @@
import * as React from "react"
import { graphql, PageProps } from "gatsby"
import Layout from "../../components/organisms/Layout"
const Blog = ({ data: { allMdx } }: PageProps<Queries.BlogQuery>) => {
console.log("allMdx", allMdx)
return (
<Layout pageTitle="Blog">
{allMdx.edges.map(({ node: post }) => (
<a href={`//${location.host}/blog/${post.slug}`}>
<h2>{post.frontmatter?.title}</h2>
</a>
))}
</Layout>
)
}
export const query = graphql`
query Blog {
allMdx {
edges {
node {
id
slug
frontmatter {
title
published
}
}
}
}
}
`
export default Blog

View file

@ -0,0 +1,33 @@
import * as React from "react"
import { graphql, PageProps } from "gatsby"
import { MDXRenderer } from "gatsby-plugin-mdx"
import Layout from "../../components/organisms/Layout"
import { defineCustomElements as deckDeckGoHighlightElement } from "@deckdeckgo/highlight-code/dist/loader";
deckDeckGoHighlightElement();
const BlogPost = ({ data: { mdx } }: PageProps<Queries.BlogPostQuery>) => {
return (
<Layout pageTitle={mdx?.frontmatter?.title ?? ""}>
<MDXRenderer>
{mdx?.body ?? ""}
</MDXRenderer>
</Layout>
)
}
export const query = graphql`
query BlogPost($id: String) {
mdx(id: {eq: $id}) {
id
body
frontmatter {
title
published
updated
}
}
}
`
export default BlogPost