Giter Site home page Giter Site logo

gatsby-v3-blog's Introduction

GATSBY MDX BLOG

Initially Recorded with V2

Changes

  1. Layout imported in every page instead of gatsby-browser.js
  2. No Instagram Component
  3. Boring Components First

Project Setup

  1. Base - Gatsby Hello World
  2. Components + Imports - ready
  3. main.css + styled components
  4. constants (different setup)
  5. Complete React Components for MDX

Boring Components

  1. Home Page
  2. Navbar
  3. Sidebar
  4. Hero
  5. Footer
  6. Error Page
  7. Newsletter
<form
  className="contact-form"
  name="contact"
  method="post"
  netlify-honeypot="bot-field"
  data-netlify="true"
  action="/success"
>
  <input type="hidden" name="bot-field" />
  <input type="hidden" name="form-name" value="contact" />
</form>
  1. Success Page (optional);

Basic MDX Setup

  1. Install mdx plugin
  2. Add gatsby-plugin-mdx to gatsby-config
  3. Setup Page - pageName.mdx /pages
  4. Basic Markdown Syntax Highlighting - MDX EXTENSION
  5. Basic Styling
  6. Add React Components including Gatsby Link
  7. New Line Gotcha

Multiple Posts

  1. Setup Posts Folder
  2. Add New filesystem Instance to gatsby-config
{
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `posts`,
        path: `${__dirname}/src/posts`,
      },
    },
  1. Create a Brand New Folder For Post Won't Query Name - setup is up to you
  2. Add mdx file
  3. DOUBLE CHECK PATHS (../../ - gotcha)
  4. Run 'gatsby clean' - just to be on the safe side
  5. Seperate Images Folder
  6. FrontMatter (space gotcha - title: first post)
  7. Imports after FrontMatter

Create MDX/Post Pages Programatically

  1. Setup Query with unique value (most likely slug)
  2. Setup Template
  3. Run Query in gatsby-node.js - just like normal setup
  4. Pass Variable (slug)
  5. Run Query in Template using variable (slug)

Create Categories Pages Programatically

  1. Repeat the same steps as posts just for categories.

Add INLINE Images to MDX

  1. Syntax - ![](./pathToImages/imageName - if in the same folder)

  2. Install - gatsby-transformer-remark

  3. Changes in gatsby config

    remove - 'gatsby-plugin-mdx' add

{
      resolve: `gatsby-plugin-mdx`,
      options: {
        gatsbyRemarkPlugins: [{ resolve: "gatsby-remark-images" }],
      },
    },
  1. Restart the server
  2. Whitespace gotchas and "gatsby clean"
  3. Styling - Good Luck!

Videos

[Gatsby Video Reference] : https://www.gatsbyjs.org/docs/working-with-video/

Reg Video

  1. The same as regular video
  2. autoPlay - gotcha
  3. use like regular component

Iframe

  1. Gatsby Docs
  2. Gotchas - url, styling
  3. Use in template - johnsmilga.com

MDX Wrapper

  1. Gatsby wrapRootElement [Wrap Root Element ] : https://www.gatsbyjs.org/docs/browser-apis/#wrapRootElement
  2. MDX [MDX Reference] : https://mdxjs.com/getting-started
  3. Gatsby/MDX Reference [ Elements Reference] : https://www.gatsbyjs.org/docs/mdx/customizing-components/

prism-react-renderer

npm install --save prism-react-renderer
  1. our code - props.children.props.children.trim()
  2. language - props.children.props.className className.replace(/language-/,'')
  3. theme

gatsby-v3-blog's People

Contributors

john-smilga avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.