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

@jbolda/gatsby-theme-articles

v0.4.6

Published

Gatsby theme to construct pages for each of your articles.

Downloads

6

Readme

@jbolda/gatsby-theme-articles

Installation

Install from npm or yarn:

npm install @jbolda/gatsby-theme-articles

or

yarn add @jbolda/gatsby-theme-articles

We also rely on peer dependencies of the following packages. Consult the package installation guides for each to potentially additional peer dependencies that require installation.

yarn add @jbolda/gatsby-theme-layout@^0.0.7 gatsby-plugin-mdx@^1.0.49 gatsby-plugin-sharp@^2.2.31 gatsby-plugin-theme-ui@^0.3.0 gatsby-source-filesystem@^2.1.0 gatsby-transformer-sharp@^2.2.20 theme-ui@^0.2.46

Convention

This plugin expects markdown files in a folder defined by a gatsby-source-filesystem config entry with a name entry of articles. The name can be configured with the contentPath option. The contentPath is in an array of objects named contents. With this configuration as an array, we can enable you to add multiple folders to "watch". This may be valuable if you have notes or drafts that should be treated separate from the main articles. You may also specify a basePath which will be prepended to your url slug, e.g. when basePath: "article" then your url might be example.com/article/my-first-post.

If you would like to use your own header, you can shadow the Nav and you don't need to include @jbolda/gatsby-theme-layout. To shadow the Nav component, place a nav.js with a Nav component exported as a default in your directory at src/@jbolda/gatsby-theme-articles/components. See the nav-shadow in the examples folder.

Configuration

Example Configuration

module.exports = {
  plugins: [
    {
      resolve: `@jbolda/gatsby-theme-articles`,
      options: { contents: [{ contentPath: "articles" }] }
    }
  ]
};

Example Configuration With Articles, Drafts In Subfolder, and Social Images

module.exports = {
  plugins: [
    {
      resolve: `@jbolda/gatsby-theme-articles`,
      options: {
        contents: [
          {
            contentPath: "articles",
            socialImages: "https://og-image.example.com/?title=${title}"
          },
          {
            contentPath: "drafts",
            basePath: "draft",
            socialImageComponent: require.resolve(
              "./src/articles/social-image.js"
            )
          }
        ]
      }
    }
  ]
};

Social Images

We support a handful of methods to get social images built into your site. This is the image that "unfurls" when posted on social media. We have an "order of importance" applied that you can mix and match even within a single contentPath.

  • The socialImage frontmatter in an article with either a full or partial url (we add the site domain for you if you have a partial url)
  • If you are using a featureImage placed in the frontmatter, we will use that.
  • In the config with a specific "content", specify a socialImages that will be applied to every piece of content. It is piped through lodash's template function and we supply the frontmatter object to it. Note that we expect a string, but you will can use the template literal ${title} syntax to have it dynamically filled in.
  • If you have gatsby-plugin-printer installed and listed in your gatsby-config.js, we will create the image for you. You cannot shadow the template used, but you can specify a socialImageComponent with require.resolve() within the content group.
  • If none of these options produce a social image, we will just not include that meta tag.

Design Tokens

The following are design tokens that are applied by variants through this theme. You may use them to apply styles to elements as a stopgap before needing to shadow a component.

{
  jboldaGatsbyTheme: {
    articles: {
      list: {
        container: { /* add tokens here */ },
        each: { /* add tokens here */ },
        heading: { /* add tokens here */ },
        text: { /* add tokens here */ },
        link: { /* add tokens here */ }
      },
      article: {
        container: { /* add tokens here */ },
        content: { /* add tokens here */ },
        footer: { /* add tokens here */ },
        featuredImage: { /* add tokens here */ },
        heading: { /* add tokens here */ },
        text: { /* add tokens here */ },
        link: { /* add tokens here */ },
        components: { /*
          add components here as shown in mdx docs,
          we pass this to the provider */
        }
      }
    }
  }
}