-
Notifications
You must be signed in to change notification settings - Fork 10
/
gatsby-node.ts
44 lines (42 loc) · 1.08 KB
/
gatsby-node.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { GatsbyNode } from "gatsby";
import { resolve } from "path";
export const createPages: GatsbyNode["createPages"] = async ({
actions,
graphql,
}: any) => {
const { createPage } = actions;
const allMdx: { errors?: any; data?: any } = await graphql(`
query MarkdownQuery {
allMdx(sort: { frontmatter: { priority: ASC } }) {
nodes {
frontmatter {
slug
title
author
linkedin
}
internal {
contentFilePath
}
body
tableOfContents
}
}
}
`);
const markDownTemplate = resolve(`src/designs/static.tsx`);
allMdx.data?.allMdx.nodes.forEach((node: any) => {
createPage({
path: `/docs${node.frontmatter.slug}`,
component: markDownTemplate,
context: {
author: node.frontmatter.author,
linkedin: node.frontmatter.linkedin,
tableOfContents: node.tableOfContents,
title: node.frontmatter.title,
pagePath: node.frontmatter.slug,
body: node.body,
},
});
});
};