/* * This file handles rendering the pages that let users select and find notes. * See note.tsx for rendering a single note. */ import React from 'react'; import Navbar from '../components/navbar'; import { graphql } from 'gatsby'; import style from './notes.module.css'; export default ({ data, pageContext }): JSX.Element => { const posts = data.allMdx.edges; const { currentPage, numPages, rootPath } = pageContext; let prevPageLink = null; if (currentPage === 2) { prevPageLink = ( << ); } else if (currentPage !== 1) { prevPageLink = ( << ); } const shouldDisplayNav = numPages !== 1; return ( <> {posts.map(({ node }) => { const frontmatter = node.frontmatter; return (

{frontmatter.title}

{node.excerpt}

); })} {shouldDisplayNav && (

{prevPageLink} {currentPage} {currentPage !== numPages && ( >> )}

)} ); }; export const query = graphql` query IndexQuery($skip: Int!, $limit: Int!) { allMdx( sort: { order: DESC, fields: [frontmatter___date] } filter: { fileAbsolutePath: { glob: "**/src/notes/*" } frontmatter: { hidden: { ne: true } } } limit: $limit skip: $skip ) { edges { node { excerpt(pruneLength: 250) frontmatter { title date(formatString: "YYYY-MM-DD") path } id } } } } `;