58 lines
1.5 KiB
JavaScript
Executable File
58 lines
1.5 KiB
JavaScript
Executable File
import React from "react"
|
|
import { graphql } from "gatsby"
|
|
import { Link } from "gatsby"
|
|
import Layout from "../layouts/layout.js"
|
|
import SLink from "../components/SLink";
|
|
|
|
const PostLink = ({ post }) => (
|
|
<div>
|
|
<Link to={post.frontmatter.path}>
|
|
{post.frontmatter.title}
|
|
</Link>
|
|
</div>
|
|
)
|
|
|
|
const IndexPage = ({
|
|
data: {
|
|
allMarkdownRemark: { edges },
|
|
},
|
|
}) => {
|
|
edges.sort((edge1, edge2) => edge1.node.frontmatter.title.length > edge2.node.frontmatter.title.length)
|
|
const Posts = edges
|
|
.filter(edge => !!edge.node.frontmatter.date && edge.node.frontmatter.level === "1") // You can filter your posts based on some criteria
|
|
.map(edge => <PostLink key={edge.node.id} post={edge.node} />)
|
|
return (
|
|
<Layout hideFooter={true}>
|
|
<div className="wiki-wrapper">
|
|
<div className="topics-wrapper">{Posts}</div>
|
|
</div>
|
|
<div className="rssWrapper">
|
|
<SLink className="hlink" to='/rss.xml'>rss</SLink>
|
|
</div>
|
|
</Layout>
|
|
)
|
|
}
|
|
export default IndexPage
|
|
export const pageQuery = graphql`
|
|
query {
|
|
allMarkdownRemark(
|
|
sort: { order: ASC, fields: [frontmatter___title] }
|
|
filter: { frontmatter: { draft: { ne: "true" }, type: { eq: "wiki" } }}
|
|
)
|
|
{
|
|
edges {
|
|
node {
|
|
id
|
|
excerpt(pruneLength: 250)
|
|
frontmatter {
|
|
date(formatString: "MMMM DD, YYYY")
|
|
path
|
|
title
|
|
draft
|
|
level
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
` |