Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using this as an extension #37

Closed
jletey opened this issue Mar 30, 2019 · 6 comments
Closed

Using this as an extension #37

jletey opened this issue Mar 30, 2019 · 6 comments

Comments

@jletey
Copy link
Collaborator

jletey commented Mar 30, 2019

As I'm a starter with Gatsby, this may be a stupid question: I was wondering if I can somehow incorporate this into eggheadio/gatsby-starter-egghead-blog?

@johno
Copy link
Owner

johno commented Mar 30, 2019

You can! It's not as straightforward as it should be right now since you need to filter the way they're querying MDX files, but you can add it to that starter with the following steps:

Add dependency

yarn add gatsby-theme-digital-garden

Add a note

mkdir -p notes/test
echo '# Hello, world' > notes/test/hello.mdx

And then edit gatsby-config.js and gatsby-node.js

gatsby-config.js

       fbAppID: '',
     },
   },
+  __experimentalThemes: [
+    {
+      resolve: 'gatsby-theme-digital-garden',
+      options: {
+        mdx: false
+      }
+    }
+  ],
   plugins: [
     {
       resolve: 'gatsby-source-filesystem',

gatsby-node.js

@@ -72,8 +72,9 @@ exports.createPages = ({ actions, graphql }) =>
     }

     const { edges } = data.allMdx
+    const posts = edges.filter(edge => edge.node.parent.sourceInstanceName === 'posts')
     const { createRedirect, createPage } = actions
-    createPosts(createPage, createRedirect, edges)
+    createPosts(createPage, createRedirect, posts)
     createPaginatedPages(actions.createPage, edges, '/blog', {
       categories: [],
     })

There are also some missing pieces on digital-garden's end for heading config for links, but you will now be able to navigate to /notes!

@jletey
Copy link
Collaborator Author

jletey commented Mar 30, 2019

@johno You are the best ... I’ll try this in a little bit

I’ll close the issue if it works fine (it should as you basically did everything for me)!

@jletey
Copy link
Collaborator Author

jletey commented Mar 30, 2019

@johno An issue: when I query for the blog posts, the notes show up as well. Do you know how to fix this? Also, how to you set the layout that you want to use for the note pages?

@ChristopherBiscardi
Copy link
Collaborator

@johnletey as @johno described originally, the query in the egghead starter is for allMdx, so you'll have to modify it to be more specific. For example in my own blog, I add the filesystem source name as a field to the Mdx nodes, then filter by it in my query.

For the layout, you can shadow the note page by creating a file in your site at src/gatsby-theme-digital-garden/components/note.js. Then you can use whatever you want to set the layout, etc and export the component as default.

@jletey
Copy link
Collaborator Author

jletey commented Mar 30, 2019

@ChristopherBiscardi Trying this out now ... thanks for the advice!

@johno
Copy link
Owner

johno commented Jul 10, 2019

When we replace the internals for the notes/blogs this will fix itself since they will introduce their own custom types. See #58

@johno johno closed this as completed Jul 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants