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-source-copy

v0.1.3

Published

Easiest way to source copy for a Gatsby site

Downloads

1

Readme

gatsby-source-copy

The easiest way to source copy from non-technical members of your team

Installation

1. Add this package as a dependency

yarn add gatsby-source-copy

npm install --save gatsby-source-copy

2. Configure the plugin in gatsby-config.js

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-source-copy',
      options: {
        documents: [
          {
            key: '<SOME_UNIQUE_KEY>',
            id: '<GOOGLE_DOC_ID>',
          },
        ],
      },
    },
  ],
}

3. Querying copy

All queried documents will return a node with content containing a raw field with the text of the source document.

If a format has been specified, content will also contain the parsed data of the document, accessed with the target format as the key. The return-type of the formatted data depends on the format specified. For more details consult the documentation of your desired format option.

Example query

query CopyQuery {
  allCopy {
    edges {
      node {
        content {
          raw
          archieml {
            document_title
          }
          markdown {
            tokens {
              type
              text
            }
          }
        }
      }
    }
  }
}

Google Docs

Permissions

To ensure your Google Document can be sourced, make sure you have enabled anyone with a link to view the file. This can be configured in the "Share" menu.

Document ID

Sourcing content with gatsby-source-copy requires configuration containing the IDs of the target documents. This ID can be found in your Google Doc URL, commonly between d/ and /edit. For example, a document with the URL https://docs.google.com/document/d/dj2k3/edit, has the ID dj2k3.

Formats

Typically, Gatsby sites utilize transformer plugins to parse content for you to query. For example, gatsby-transformer-remark for transforming markdown. To provide better ergonomics for querying content, this plugin provides support for parsing several popular markup languages used for authoring copy. This enables simpler queries by exposing the parsed content alongside the raw text that was sourced.

By default, gatsby-source-copy will not parse your content but return the raw text of the document. To parse the contents of the document, provide a format configuration option. This option can be set globally or per document. gatsby-source-copy currently supports parsing Markdown and ArchieML.

// global
{
  resolve: 'gatsby-source-copy',
  options: {
    format: "markdown",
    documents: [...]
  }
}

// per document
{
  resolve: 'gatsby-source-copy',
  options: {
    documents: [
        {key: 'foo', id: 'ajCe2', format: "archieml"},
        {key: 'bar', id: 'a9rcf', format: "markdown"},
      }
    ]
  }
}

Parsers

| Format | Key | Parser | Example | | -------- | ------------ | --------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | | Markdown | "markdown" | marked.js | examples/markdown.md | | ArchieML | "archieml" | archieml-js | examples/archieml.txt |

Can't find the format you're looking for? Open an issue or add your own!

Contributing

This project is open to and encourages contributions! Feel free to discuss any bug fixes/features in the issues. If you wish to work on this project:

  1. Fork this project
  2. Create a branch (git checkout -b new-branch)
  3. Commit your changes (git commit -am 'add new feature')
  4. Push to the branch (git push origin new-branch)
  5. Submit a pull request!