-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnote-template.js
47 lines (42 loc) · 1.1 KB
/
note-template.js
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
45
46
47
import { MDXProvider } from '@mdx-js/react';
import { graphql } from 'gatsby';
import { MDXRenderer } from 'gatsby-plugin-mdx';
import * as React from 'react';
import { Link } from '../components/link';
import { Note } from '../components/note';
import { Seo } from '../components/seo';
const MDXComponents = {
a: ({ href, ...props }) => <Link {...props} to={href} />,
};
const NoteTemplate = ({ data, location }) => {
const { frontmatter, body } = data.mdx;
return (
<>
<Seo
title={`${frontmatter.title} - React KL`}
image={frontmatter.image && frontmatter.image.publicURL}
description={frontmatter.description}
pathname={location.pathname}
/>
<Note title={frontmatter.title}>
<MDXProvider components={MDXComponents}>
<MDXRenderer>{body}</MDXRenderer>
</MDXProvider>
</Note>
</>
);
};
export default NoteTemplate;
export const pageQuery = graphql`
query MdxById($id: String!) {
mdx(id: { eq: $id }) {
frontmatter {
title
image {
publicURL
}
}
body
}
}
`;