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

gatsby-theme-abstract-blog

v1.0.0-3

Published

A core data-abstraction theme for Gatsby.

Downloads

36

Readme

Gatsby Theme Abstract Blog

A core data-abstraction theme for Gatsby.

This theme can be used on its own, but is intended as shared abstraction layer for other themes. If you're looking for a simpler setup, see one of the following themes that are built with this theme.

  • gatsby-theme-contentful-blog
  • gatsby-theme-datocms-blog
  • gatsby-theme-wordpress-blog

Get started

Install the theme and add it to your Gatsby site's gatsby-config.js.

npm i gatsby-theme-abstract-blog
// gatsby-config.js
module.exports = {
  plugins: ["gatsby-theme-abstract-blog"],
}

This theme provides a data abstraction layer for other themes or sites to implement based on their CMS backend. It does not include pages or source content, and you'll need to provide these for the theme to render blog pages.

Add templates

This theme requires that your site include two templates in its src directory. By default it expects these templates to exist:

  • src/templates/blog-index.js
  • src/templates/blog-post.js

Add these two templates to your site.

// src/templates/blog-index.js
import * as React from "react"
import { Link } from "gatsby"

export default function BlogIndex({ posts }) {
  return (
    <div>
      <h1>Blog</h1>
      <ul>
        {posts.map((post) => (
          <li key={post.id}>
            <Link to={`/blog/${post.slug}`}>{post.title}</Link>
          </li>
        ))}
      </ul>
    </div>
  )
}
// src/templates/blog-post.js
import * as React from "react"

export default function BlogPost(props) {
  return (
    <div>
      <h1>{props.title}</h1>
      <div
        dangerouslySetInnerHTML={{
          __html: props.html,
        }}
      />
    </div>
  )
}

Add content source

Because this theme does not source content, you'll need to source content from your CMS of choice.

  1. Add a source plugin to your gatsby-config.js for your CMS
  2. Add a custom GraphQL type definition to your gatsby-node.js that implements the BlogPost interface, ensuring the shape matches the interface provided by this theme.

The following example is for WordPress, but change the node type as needed for your CMS.

// example gatsby-node.js
exports.createSchemaCustomization = async ({ actions }) => {
  actions.createTypes(`
    type WpPost implements Node & BlogPost {
      id: ID!
      slug: String!
      title: String!
      html: String! @proxy(from: "content")
    }
  `)
}

Options

// example gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: "gatsby-theme-abstract-blog",
      options: {
        postPath: "src/templates/blog-post",
        indexPath: "src/templates/blog-index",
        customQueries: false,
      },
    },
  ],
}
  • postPath: relative path to template for the blog post pages
  • indexPath: relative path to template for the blog index page
  • customQueries: set to true to use provided components as page components that include Gatsby GraphQL page queries