Tim Addison

Link Roundups

November 30, 2019

I’ve started to publish link roundups to the site. I used to share these in weekly/fortnightly newsletters at work, and as I invariably re-shared most of them outside of work anyway, figured I’d put them on the blog. I used to do these weekly, though think I’ll settled for an irregular cadence that sees them come in once or twice a month.

The links pages are implemented as markdown pages, and in order to prevent them showing up as blog posts (and in all the blog meta pages like tags, history, etc.) I used the gatsby-remark-source-name package. My gatsby-config.js now contains two markdown imports:

{
  resolve: `gatsby-source-filesystem`,
  options: {
    path: `${__dirname}/content/blog`,
    name: `blog`,
  },
},
{
  resolve: `gatsby-source-filesystem`,
  options: {
    path: `${__dirname}/content/links`,
    name: `links`,
  },
}

Anywhere I need to refer to either blog posts or links posts I can use the name attribute to disambiguate the allMarkdownRemark node - the following is an example from the gatsyby-node.js file that builds the /links pages:

{
  allMarkdownRemark(
    filter: { fields: { sourceName: { eq: "links" } } }
    sort: { fields: [frontmatter___date], order: DESC }
    limit: 1000
  ) {
    edges {
      node {
        fields {
          slug
        }
      }
    }
  }
}

You can see all the changes needed to add the new post type in this pull request. There are probably a few rough edges - I haven’t got that many links pages so pagination and navigation may require some fixes.

Once I’ve got a few more links pages up I’ll see about adding a ‘recent updates’ component to the home page, which would show a feed of posts (links or blog entries). The RSS feed probably needs some attention to, as does the navigation (now there are blogs and links to worry about!).

For now I’m just glad to share the keystrokes with a wider audience.

#Blog#GatsbyJS