GithubHelp home page GithubHelp logo

pauliescanlon / gatsby-theme-gatstats Goto Github PK

View Code? Open in Web Editor NEW
36.0 6.0 3.0 48.68 MB

A Gatsby theme and dashboard for your tech blog... or a dashblog if you prefer 🤷‍♂️

Home Page: https://gatsby-theme-gatstats.netlify.com/

JavaScript 8.91% TypeScript 90.23% CSS 0.85%
gatsby gatsbyjs gatsby-theme

gatsby-theme-gatstats's Introduction

gatsby-theme-gatstats main image

npm (scoped)

npm

NPM

Netlify Status

GatStats is a dashboard for your tech blog.

... or a dashblog if you prefer? 🤷‍♂️

Properties sourced from frontmatter in src/posts/[name].mdx are used to create data visualizations to wow your readers.

👁️ Preview

🚀 Getting started

Install

npm install @pauliescanlon/gatsby-theme-gatstats

Setup

gatsby-config.js

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

module.exports = {
  siteMetadata: {
    title: "Your blog title",
    description: "I like tech",
    keywords: ["tech", "blog", "boop"],
    siteUrl: 'https://gatsby-theme-gatstats.netlify.com/',
    siteImage: 'name-of-open-graphy-image.jpg', // pop an image in the static folder to use it as og:image
    config: {
      headerHeight: 64,
      sideBarWidth: 240,
      twitter: 'pauliescanlon', // no need to include the @
      github: 'pauliescanlon'
    },
  },
  plugins: ['@pauliescanlon/gatsby-theme-gatstats']
}

directory structure

If you'd like to add more pages and posts add them to your src dir.

|-- src
    |-- pages
        |-- about.mdx
    |-- posts
        |-- year-post-dir
            |-- some-post-dir
                |-- some-post.mdx
                |-- some-image.jpg
                |-- some-embedding-image.jpg

frontmatter setup

For pages use the following template. The icon field is a path for any icon. This is an example is from Material Icons. The icon property is whats used to determine if an .mdx file is a page or a post. Pages appear in the side bar navigation

---
title: About
icon: 'M12 6c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2m0 10c2.7 0 5.8 1.29 6 2H6c.23-.72 3.31-2 6-2m0-12C9.79 4 8 5.79 8 8s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 10c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z'
---

# Demo About

This is about from the demo

For posts use the following template

---
title: Some Post
tags: ["Gatsbyjs", "React"]
date: 2019-11-13
status: draft // setting the status to draft hides the post from blog
featuredImage: some-image.jpg
embeddedImages:
  - some-embeddedImage.jpg
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

🖼️ Embedding Images

Embedding images into .mdx can be tricky but using MdxRenderer we can still use frontmatter to pass graphQL image data to any part of the post body

frontmatter

Add locally sourced images to frontmatter using embeddedImages then pass a reference to them to the <EmbeddedImage /> component via props.

The <EmbeddedImage /> component is part of the theme and is passed to all .mdx files using the MDXProvider so you don't have to import anything for this to work.

There's a couple of optional helper props for width and justifyContent so you get a bit more control over size and alignment.

EmbeddedImage

The <EmbeddedImage /> component accepts a width prop which can be used to control the image size. The width prop can either be a single string which will apply the the same size across all breakpoints or an array of sizes to use across the breakpoints defined in the theme.

---
embeddedImages:
  - image1.jpg
  - image2.jpg
---

Post body text

<EmbeddedImage
  src={props.embedded.image1}
  width={['100%', '75%', '50%', '25%']}
/>

More post body text

<EmbeddedImage
  src={props.embedded.image2}
  width="25%"
  justifyContent="center"
/>

👥 Component Shadowing

You know about component shadowing right? By shadowing the filePath/fileName you can replace any component in the theme with your own.

Once such component might be src/components/Code/Code.tsx this file is in charge of formatting code snippets. For the time being the only way to format the colours used in code snippets is to change the theme used by prism-react-renderer

If you need to re-style the code snippets shadow this component and change the bits you need.

ko-fi

gatsby-theme-gatstats's People

Contributors

firefox0102 avatar jlengstorf avatar pauliescanlon avatar

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gatsby-theme-gatstats's Issues

Donut Chart Legend

Overlaying the donut chart with the legend keys kinda works ok for tags with short names but for longer names they can break out of the pie segment so perhaps putting these in a nice list would be better.

Add query param for filtered tags

When a user selects a tag to filter by on the posts page push this to the url.

also on page load we should check the query param and apply the filter by it and populate the dropdown if its there.

Add Tooltips to charts

Add tooltips or some other visual representation of the amount the line or pie or bar represents

Dashboard Totals

Under the bio design up some total statistics

Total words
Total reading time
Total post
Total tags usged

if poss might be able to get total posts with images
... and / or total posts with youTube embed or total posts with code snippet

Nested anchor <a>

Currently if the Theme see's <a> it'll just style it so that it works nicely within a <p> i was only considering links being used as part of paragraph text that would link out somewhere.

Having just written a post where using headings as a # anchor would be useful i need to investigate how to ensure <a> tags inherit the correct styling depending on how they are used.

More metrics in dashboard

Would be nice to add some more metrics/viz like:

  • Most popular posts
  • Most popular tags (as in number of views)

Post footer / prev - next posts

Might be good to have a little thumbnail image at the bottom of the posts on left and right which navigates to the next or prev post

npm README

Currently because i'm using yarn workspaces the repo has a root level README which is great if you're landing on GitHub and want to see how to use GatStats but if you're entry is directly on npm then the README you see here is the README from src/gatsby-theme-gatstats

In both cases the README needs to contain pretty much the same stuff, perhaps less so from npm as you won't be needing info about how to develop but for the most part its the same

Looking at a little pre publish or pre commit hook that will copy the contents of the root README and paste it into src/gatsby-theme-gatstats so the two stay in sync. Then it wont matter what your entry point is

Add GoogleAnalytics to demo

Might be good to have some analytics so i can see where the hits are coming from.

Need to investigate environment vars on Netlify

Logo not always visible

Currently the Logo sits in the SideBar and is not visible at the md breakpoint when the SideBar becomes hidden until interacted with via the burger menue

Consider a few things

move the burger menu to the right (md breakpoint)
hide the theme toggle (md breakpoint) in header
show Logo in header (md breakpoint)
show theme toggle in sidebar / bottom of sidebar (md breakpoint)
theres also the <- arrow when the user is on a post route, maybe that can be a floating action bottom positioned bottom right

overflow scroll on sidebar

currently if the side by nav list exceeds the viewport height nav items will no long be visible.

refactor the sidebar and allow an overflow scroll on the y to allow for scrolling if the nav list exceeds view port height. Might require a little something under the logo so that this remains fixed and content scrolls beneath it.

Embedded Images

frontmatter already deals with the featuredImage which gets added to the top of each post.

If further images are required in a post it would be nice to query additional frontmatter so that MdxRenderer can be passed data for embedded images.

The key difference is i guess that if we pass MdxRenderer the graphQL image query as a prop it can be used anywhere in the body of the post

eg

---
embeddedImages:
  - './path-to-image-1'
  - './path-to-image-2''
---
import {EmbeddedImage} from "@pauliescanlon/gatsby-theme-gatstats/src/components ...."
<EmbeddedImage src={props.embedded.image1} /> 

Post body text

<EmbeddedImage src={props.embedded.image2} />

More post body text

Dashboard bugs

As mentioned in the email, the posts line chart can get out of scale. Also the days of the week chart somehow doesn’t show up a Sunday post.

Tags theme color range

Currently the colors are hard coded that create the color range required for the tags, so adding new colors to the theme has no effect on their styles.

This needs to be the primary and secondary color from the theme but since its outside of a sx prop i'll need to source the colors using theme-ui's const context = useThemeUI() then pass the primary and secondary colors onto the color-range util

SEO image head tags broken

Some meta tags in components/seo/seo.tsx don't take into account the static folder https://www.gatsbyjs.org/docs/static-folder/

In particular the
<meta property="og:image" content={${siteURL}/images/${image ? image : ''}} />

and
<meta name="twitter:image" content={${siteURL}/images/${image ? image : ''}} />

and
<meta name="image" content={${siteURL}/images/${image ? image : ''}} />

have the /images/ path hardcoded which results in a 404 error for those URLs when using the static folder.
For example an URL will get rendered as /images//static/33b46d14fb5cb9d3eb5a3de9c253cb03/b90bb/IMG_1234.jpg

while it should be
/static/33b46d14fb5cb9d3eb5a3de9c253cb03/b90bb/IMG_1234.jpg

So let's say you have the following folder structure:

  • static
    • some files
    • images
      -apple-touch-icon.png
      -favicons.png

Then favicons and apple-touch-icon.png (for meta name="image") will correctly work in the dashboard page for example but posts will have the bug described above.

Time to read suffix

Currently Time to read has no numerical suffix so the user cant tell what unit of measurement we're talking about, is it seconds, hours, etc. Might need some kind of time util for this.

Storybook - YearChart error

I love the theme - nice work!

I found an error in the Storybook YearChart section:
image

Error:

TypeError: Cannot read property 'map' of undefined
    at YearChartComponent (https://gatsby-theme-gatstats.netlify.com/storybook/main.4a424575b496f6b1c88b.bundle.js:1:45739)
...

Advanced frontmatter template

Useful tags would be:

  • 'dateUpdated', so that it's possible to revise/update a post and still display the original publish date alongside the updated one
  • 'status', can get values like 'published' and 'draft'. While status is draft, we can still write and save on git a draft of the post/page but it won't get built during gatsby build. Particularly useful for common CI/CD environments

Header padding

Investigate the header padding, looks like the logo and menu on small screens doesn't line up with the padding on the posts and or main content

SEO

There is currently no SEO in the site.

This needs to added to pages and posts.
Using the information from siteMetaData and or Frontmatter some head tags should be populated

Latest Posts "2 new Posts"

Currently Latest posts has a hard coded subHeading of "2 new posts" whilst this components only displays a maximum of 2 posts it will still display "2 posts" even if you only have 1.

Maybe just change the wording here so theres no numerical reference to the amount of latest posts

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.