1
1
mirror of https://github.com/jxnblk/mdx-deck.git synced 2024-09-11 06:35:24 +03:00

Edit gatsby theme

This commit is contained in:
Brent Jackson 2020-01-31 12:48:49 -05:00
parent b839e11b3b
commit dc7760e5fe
4 changed files with 15 additions and 1 deletions

View File

@ -8,3 +8,4 @@
---
HMR *should* work now

View File

@ -43,6 +43,12 @@ const mdxResolverPassthrough = fieldName => async (
return result
}
const resolveTitle = async (...args) => {
const headings = await mdxResolverPassthrough('headings')(...args)
const [first = {}] = headings
return first.value || ''
}
exports.createSchemaCustomization = ({ actions, schema }) => {
actions.createTypes(
schema.buildObjectType({
@ -52,6 +58,10 @@ exports.createSchemaCustomization = ({ actions, schema }) => {
slug: {
type: `String!`,
},
title: {
type: 'String!',
resolve: resolveTitle,
},
body: {
type: `String!`,
resolve: mdxResolverPassthrough(`body`),
@ -72,6 +82,7 @@ exports.createPages = async ({ graphql, actions, reporter, pathPrefix }) => {
node {
id
slug
title
}
}
}

View File

@ -71,7 +71,7 @@ const DefaultMode = ({ children }) => <React.Fragment children={children} />
export default ({
slides = [],
pageContext: { slug },
pageContext: { title, slug },
theme = {},
themes = [],
...props
@ -112,6 +112,7 @@ export default ({
return (
<>
<Helmet>
{title && <title>{title}</title>}
{head}
</Helmet>
<GoogleFont theme={mergedTheme} />

View File

@ -9,6 +9,7 @@ export const pageQuery = graphql`
deck: deck(id: { eq: $id }) {
id
body
title
}
}
`