rickvanlieshout.com/internal/gatsby/queries/pages-query.ts

36 lines
722 B
TypeScript
Raw Permalink Normal View History

import { CreatePagesArgs } from "gatsby";
import * as types from "../types";
export interface PagesQueryResult {
allMarkdownRemark: {
edges?: Array<types.Edge>;
};
}
const pagesQuery = async (graphql: CreatePagesArgs["graphql"]) => {
const result = await graphql<PagesQueryResult>(`
{
allMarkdownRemark(filter: { frontmatter: { draft: { ne: true } } }) {
edges {
node {
frontmatter {
template
}
fields {
slug
readingTime {
text
}
}
}
}
}
}
`);
return result?.data?.allMarkdownRemark?.edges ?? [];
};
export default pagesQuery;