npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@smerth/gatsby-theme-events

v1.2.2

Published

Install events content type in a gatsby site with data source and page rendering

Downloads

3

Readme

Gatsby Theme Events

IMPORTANT! - this theme is not meant for use in a live site. I am using this package as a place to learn about gatsby theming. I am going to make breaking changes!!

Overview

This is the code base for the NPM package: @smerth/gatsby-theme-events

The repo contains the theme and a site for testing the theme, organised as a yarn workspace. The two workspaces are:

  • site
  • @smerth/gatsby-theme-events

@smerth/gatsby-theme-events creates a simple events content type and adds a listing page for events and a page for each separate event.

This theme is based on the free online course gatsby-theme-authoring by Jason Lengstorf at the egg-cellant Egghead.IO with the following changes:

  • implementation of a custom grahpql interface to merge json and yaml data sources into a single graphql type called event
  • use of the new gatsby-plugin-theme-ui
  • example of using the JSX prama /** @jsx jsx */ in the StyledLink component be able to access theme.js variables to style the Gatsby Link component

Usage:

Data source:

Either an events.json or an events.yaml file, (or both,) must be added to a data source folder.

Events data should take this form:

[
  {
    "id": "6d9aecc5-722a-4562-aa18-c30b01d8484a",
    "name": "convallis duis consequat dui nec",
    "location": "62538 Di Loreto Place",
    "start_date": "2019-01-16",
    "end_date": "2019-06-13",
    "url": "https://nba.com/non/interdum.json"
  },
  {
    "id": "8702366c-b742-4832-9b28-fbb079edceb6",
    "name": "lobortis sapien sapien non mi",
    "location": "742 Rigney Junction",
    "start_date": "2019-04-13",
    "end_date": "2019-01-23",
    "url": "http://bloomberg.com/eget/rutrum/at.jpg"
  },

or, for yaml this:

- id: dc6a999d-292b-4fa4-bbb5-e87f39f53128
  name: nulla justo aliquam quis turpis
  location: 6122 Grayhawk Road
  start_date: "2019-02-02"
  end_date: "2018-10-29"
  url: http://google.cn/felis/eu/sapien/cursus/vestibulum/proin.jpg
- id: 64d24fe6-1084-45ff-bc05-e173c8efd642
  name: ante ipsum primis in faucibus orci
  location: 91212 Dorton Place
  start_date: "2018-08-17"
  end_date: "2019-04-25"
  url: http://craigslist.org/libero.png

By default the theme creates a data folder @ host-site/site/src but this can be overridden in the plugin config. The base path for listing and event pages can also be set in the config, like this:

@ host-site/gatsby-config.js

module.exports = {
  plugins: [
    {
      resolve: "@smerth/gatsby-theme-events",
      options: {
        basePath: "/events",
        contentPath: "events"
      }
    }
  ]
};

Theme UI

The theme uses gatsby-plugin-theme-ui to deliver a theme object to components. The theme.js file and any components can be overriden using "component shadowing".

GraphQL Customization

This theme contains an example of customizing Gatsby's GraphQL Schema.

An event interface is defined. This interface is then implemented by the jsonEvents and yamlEvents types.

Field extentions are used to rename fields (for example: @proxy(from: "start_date")), and to set date formats (for example: @dateformat.)