GithubHelp home page GithubHelp logo

pauliescanlon / gatsby-theme-terminal Goto Github PK

View Code? Open in Web Editor NEW
311.0 5.0 35.0 7.79 MB

A zero component Gatsby theme for developers ๐Ÿ”‹

Home Page: https://gatsbythemeterminal.gatsbyjs.io/

JavaScript 99.76% Shell 0.24%
gatsby gatsbyjs gatsby-theme mdx

gatsby-theme-terminal's Introduction

gatsby-theme-termninal main image

gatsby-theme-terminal

Gatsby Theme Terminal aims to be a zero component theme. It provides data components to aid in the abstraction of presentational and data layers which together provide the most flexibility

The theme handles the data but how it's displayed is up to you!

You can create any page layout or component combination you like using your own components or components provided by theme-ui/components

๐Ÿ‘€ Preview

๐Ÿš€ Getting started

To help you get started you can either clone the starter gatsby-starter-terminal or read the below.

Install

npm install @pauliescanlon/gatsby-theme-terminal

Install Peer Dependencies

npm install @mdx-js/mdx @mdx-js/react gatsby gatsby-plugin-mdx gatsby-source-filesystem react react-dom

Setup

gatsby-config.js

Add the siteMetaData and @pauliescanlon/gatsby-theme-terminal to your gatsby-config.js

// gatsby-config.js
module.exports = {
  siteMetadata: {
    name: "Your blog title",
    description: "I like tech",
    keywords: ["tech", "blog", "boop"],
    siteUrl: 'https://gatsby-theme-terminal.netlify.com',
    siteImage: 'name-of-open-graph-image.jpg', // pop an image in the static folder to use it as the og:image,
    profileImage: 'name-of-profile-image.jpg'
    lang: `eng`,
    config: {
      sidebarWidth: 240 // optional,
    },
  },
  plugins: ['@pauliescanlon/gatsby-theme-terminal']
}

directory structure

To add pages create .mdx files in the src/pages directory. You need at least one file called index.mdx located at src/pages or you'll see a GraphQL error.

|-- src
    |-- pages
        |-- index.mdx
        |-- about.mdx
        |-- contact.mdx 

frontmatter setup

Pages

Pages must include navigationLabel in the frontmatter

// src/pages/about.mdx
---
navigationLabel: About
---

# About

This is about page

Theme options

Additional .mdx can be sourced from anywhere outside the pages directory but you need to tell the theme where to source these files from.

Use the source option in gatsby-config.js

// gatsby-config.js
...
  plugins: [
    {
      resolve: `@pauliescanlon/gatsby-theme-terminal`,
      options: {
        source: [
          {
            name: "posts",
            dir: "posts",
          },
          {
            name: "projects",
            dir: "projects",
          },
        ] // can be an object or array of objects

      },
    },
  ],
}

Then create the relevant files and directories

|-- src
    |-- pages
    ...
    |-- posts 
      |--2020
        |--02
          |-- some-post.mdx
          |-- featuredImage: markus-spiske-466ENaLuhLY-unsplash.jpg
          |-- markus-spiske-FXFz-sW0uwo-unsplash.jpg
    |-- projects
      |-- some-project.mdx  

Any file that is not sourced from pages can contain any of the following frontmatter but a title is required, this is how the theme distinguishes between pages and other .mdx files

// src/posts/2020/02/some-post.mdx
---
title: Some Post
tags: ["JavaScript", "React", "GatsbyJs", "HTML", "CSS", "theme-ui"]
date: 2020-01-01
dateModified: 20-20-2020
author: Paul Scanlon
status: draft // => means it won't be rendered
isPrivate: // => it will be rendered but you can use this prop as a filter
url: "https://example.com"  // => could be an external url
misc: "Ahoy" // => use how you wish
pinned: false // => Could be used as a filter for pinned posts
featuredImage: markus-spiske-466ENaLuhLY-unsplash.jpg
featuredImageUrl: https://via.placeholder.com/936x528
embeddedImages:
  - markus-spiske-FXFz-sW0uwo-unsplash.jpg
embeddedImageUrls:
  - https://via.placeholder.com/468x264
---

Embedded Images

By using the The <GatsbyImage /> component from gatsby-plugin-image you can pass the image data queried by GraphQL and pass it on via the image prop

The gatsbyImageData, data is available via props.embedded.image(n)

<GatsbyImage image={props.embedded.image1} />

You can also use the Theme UI <Image /> component by passing it a src

<Image src={props.embedded.image1.gatsbyImageData.images.fallback.src} />

image1 in this example would be markus-spiske-FXFz-sW0uwo-unsplash.jpg

EmbeddedImages can also be sourced from a remote url, in this case use the <Image /> component and pass it the same props

<Image src={props.embedded.image2.gatsbyImageData.images.fallback.src} />

markdown

The theme supports the complete markdown spec and you can see how to use markdown in the demo

theme-ui/components

The theme supports all the components provided by theme-ui/components and you can see in the demo how they are used.

gatsby-theme-terminal/components

The theme also comes with it's own components but... These are purely to provide access to the source nodes. What you choose to render is completely up to you!

For example to display a list of all files sourced from the source theme option you could do something like this. This component can be used in ANY .mdx file ๐Ÿ˜Ž

<SourceList>
  {(source) => (
    <ul>
      {source.map((edge, index) => {
        const {
          frontmatter: { title },
        } = edge.node
        return <li key={index}>{title}</li>
      })}
    </ul>
  )}
</SourceList>

You can see more about how to use the theme components in the demo

Component Shadowing

There is very little to shadow because almost everything is exposed by the components but you might want to add your own logo.

To do this create the following directories @pauliescanlon/gatsby-theme-terminal/components/Logo in the src directory of your project and then create a Logo.js file. You can do anything you like in here.

|-- src
    |-- @pauliescanlon
      |-- gatsby-theme-terminal
        |-- components
          |-- Logo
            |-- Logo.js

If you would like to customize any part of the theme you can do so by shadowing the theme file.

To do this create the following directory src/gatsby-plugin-theme-ui and then create an index.js

// src/gatsby-plugin-theme-ui/index.js

import baseTheme from '@pauliescanlon/gatsby-theme-terminal/src/gatsby-plugin-theme-ui'

export default {
  ...baseTheme,
  colors: {
    ...baseTheme.colors,
    primary: '#FF4081',
    secondary: '#03A9F4',
    success: '#FFEB3B',
    background: '#232323',
    surface: '#393939',
  },
}

favicon

favicon(s) need to be saved in static/images and named favicon-16x16.png and favicon-32x32.png along with an .icon file called favicon.ico

If you're using gatsby-theme-terminal in your project i'd love to hear from you @pauliescanlon

ko-fi

gatsby-theme-terminal's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gatsby-theme-terminal's Issues

prev / next :bug

investigate how the prev and next links work. Do they do it by date or by what ever the last modified mdx file was.

paulie.dev Skin UI post: hit prev and you should the gatsby-theme-terminal post, instead you see the prop-shop post.

It might be the dates in frontmatter aren't correct so check those against the date format used in the gatsby-theme-terminal demo.

Make gatsby-plugin-google-fonts plugin optional

Would it be possible to make the Google Fonts plugin optional, or remove it entirely? I'd like to use a different font, and my only option to drop the Inconsolata load seems to be forking the theme.

Love this theme's look and approach, thanks!

Local development - Fonts + CORs error

Hey there, thanks for the great theme! I'm new to Gatsby and decided to rebrand my site using your template but ran into an interesting console message. The message results in the Inconsolata font not loading and until I installed Inconsolata is a local font, it rendered as just the generic monospace font.

Access to font at 'https://example.com/fonts/Inconsolata-Regular.woff2' from origin 'http://localhost:8000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I get this when I run the npm run develop command.

Code blocks in Posts cause build failure

Certain elements of markdown cause the Gatsby build to fail when used in Posts (but not in pages). Is it expected that all markdown features are not available in Posts? I also noted that inline backtick-delimted code blocks are not highlighted. Hopefully I haven't simply failed to read the docs correctly.

The error log below is generated when I try to insert a triple backtick delimited code block in a Post:

8:25:09 PM: failed Building static HTML for pages - 8.449s
8:25:09 PM: error Building static HTML failed for path "/posts/notion-count-open-tasks/"
8:25:09 PM: 
8:25:09 PM:   107 |       props = _objectWithoutProperties(_ref, ["children", "className", "title"]);
8:25:09 PM:   108 | 
8:25:09 PM: > 109 |   var _outerClassName$repla = outerClassName.replace(/language-/, '').split(' '),
8:25:09 PM:       | ^
8:25:09 PM:   110 |       _outerClassName$repla2 = _slicedToArray(_outerClassName$repla, 1),
8:25:09 PM:   111 |       language = _outerClassName$repla2[0];
8:25:09 PM:   112 | 
8:25:09 PM: 
8:25:09 PM:   WebpackError: TypeError: Cannot read property 'replace' of undefined
8:25:09 PM:   
8:25:09 PM:   - prism.esm.js:109 
8:25:09 PM:     node_modules/@theme-ui/prism/dist/prism.esm.js:109:1
8:25:09 PM:   
8:25:09 PM: 
8:25:09 PM: โ€‹
8:25:09 PM: โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
8:25:09 PM:   "build.command" failed                                        
8:25:09 PM: โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
8:25:09 PM: โ€‹
8:25:09 PM:   Error message
8:25:09 PM:   Command failed with exit code 1: gatsby build
8:25:09 PM: โ€‹
8:25:09 PM:   Error location
8:25:09 PM:   In Build command from Netlify app:
8:25:09 PM:   gatsby build

Removing the code block lets the build succeed.

As an example, some of my markdown for a paragraph in a test blog post is below - you will see that the inline code blocks don't render and also that the h2 styling is different to the intended theme styling for h2 content on pages.

## Notion setup

I have a `Tasks` database that collects all to-do items from all of my `Projects` through a standard Notion relationship. The task list in each project page is simply a mirrored list of the main `Tasks` database filtered to show only tasks related to that project.

If there was a `Count` function in Notion it would be trivial to know how many open tasks there are, but since there isn't (currently?) we need to set up a couple of helper columns in the `Projects` database to allow us to show the number.

Make gatsby-plugin-theme-ui optional

Sorry to bomb you, related to my other issue, wondering if you'd consider making the theme-ui plugin optional. I realize that's the standard theme-ui plugin, but the blocking approach they take to support color modes can have a big impact on Lighthouse (and possibly other) profilers. See issue.

I realize you rely heavily on theme-ui, so for most folks they could install the plugin as a peer. In my case, I could import your theme and present to my own site's wrapRootElement implementation.

Posts not sorted by date

Hi,
Thanks for putting this amazing theme on Github! I am trying to port my website to this theme and noticed that the posts are not sorted by date. I am not familiar with React and Gatsby, but I tried making a few changes in the code but failed.

Things that I tried:

  1. in posts.mdx
posts
+        .sort((a, b) =>  new Date(a.date) - new Date(b.date))
        .map((edge, index) => {
  1. in useAllMdx.js
allMdx {
      allMdx(
        filter: {
          frontmatter: {
            title: { ne: "dummy" }
            navigationLabel: { ne: "dummy" }
            status: { ne: "draft" }
          }
          fields: { owner: { eq: "source" } }
+          sort: { fields: [frontmatter___date], order: DESC }
        }

source days: bug

Investigate the source days data component. It might be returning the wrong number for the day, or might be using the wrong number to look up the day name.

I posted on April 1 2020 which is a Wednesday but on paulie.dev the count for Thursday incremented by one and there are no posts for Wednesday in the chart.

How do I change PostList A2 to PostList A1 ?

image

<ul
  sx={{
    listStyle: 'none',
    m: 0,
    px: 3,
    py: 4,
  }}>
  {posts.map(post => (
    <li key={post.id}
      sx={{
        mb: 4,
      }}>
      <Styled.h2
        sx={{
          m: 0,
        }}>
        <Link to={post.slug}
          sx={{
            color: 'inherit',
            textDecoration: 'none',
            ':hover,:focus': {
              color: 'primary',
              textDecoration: 'underline',
            }
          }}>
          {post.title}
        </Link>
      </Styled.h2>
      <small sx={{ fontWeight: 'bold' }}>{post.date}</small>
      <Styled.p>
        {post.excerpt}
      </Styled.p>
    </li>
  ))}
</ul>

Posible bug: routing of multiple categories

I had a problem where if I would want to create another category, lets say portfolio alongside posts, that filter in was not working and was listing both project and portfolio items. Also route for single posts wasn't just 'posts' but it became
localhost/posts,portfolio/name-of-post.
After I downloaded you demo and ran it locally same thing happened.

I'm only beggining to explore gatsby, so I'm not sure could it be something on my environment setup, but I tough that only thing I need to do to configure multiple categories of posts is to set it like this

plugins: [ { resolve:@pauliescanlon/gatsby-theme-terminal, options: { source: [posts, portfolio], // can be a string or array of strings }, }, ],

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.