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 🙏

© 2026 – Pkg Stats / Ryan Hefner

gatsby-attainlabs-cms

v1.2.22

Published

A Gatsby plugin that downloads and syncs components from the **Attain Labs CMS** hosted in Azure Repos into your Gatsby project at build time.

Readme

gatsby-attainlabs-cms

A Gatsby plugin that downloads and syncs index.tsx components from the Attain Labs CMS hosted in Azure Repos into your Gatsby project at build time.

This is especially useful for keeping brand-specific and global CMS blocks up to date across Gatsby projects without manual copying.


Installation

npm install gatsby-attainlabs-cms

Setup

1. Add environment variable

At the root of your Gatsby site, create a .env file if it doesn’t already exist:

touch .env

Inside the file, add your Azure DevOps Personal Access Token (PAT):

PERSONAL_ACCESS_TOKEN=xxxxxxxxxxxxxxxx

⚠️ Do not prefix this with GATSBY_.
That prefix exposes variables to the browser bundle, which is not safe for secrets.


2. Load .env in Gatsby

At the top of your gatsby-config.js, load dotenv:

require("dotenv").config({
  path: `.env.${process.env.NODE_ENV}`,
});

3. Configure the plugin in gatsby-config.js

module.exports = {
  plugins: [
    {
      resolve: "gatsby-attainlabs-cms",
      options: {
        brand: "Cash Money", // LendDirect | Cash Money | Heights Finance | Attain Finance
        // personalAccessToken: "optional-fallback", // not recommended, but supported
        environment: "production", // production | staging | dev
        // azureBranch: "my-feature-branch", // Optional: Override branch for non-production environments
        fetch: ["blogs", "disclaimers", "faqs"], // Array of data to fetch from database
        debug: false, // Console logs blocks created
      },
    },
  ],
};

Environment Options

  • production: Forces content sync from the master branch.
  • staging: Automatically fetches content from the latest active Pull Request branch in Azure DevOps. Falls back to master if no PR is active.
  • dev: Skips component sync and data fetching. Useful for local development speed.
  • Default behavior: If environment is unspecified or other values, it defaults to the azureBranch option or master.

---

## Behavior

- Downloads brand-specific components into:
  - `src/cms/components/brand/`
  - `src/cms/components/global/`
  - `src/cms/gatsby-plugin-theme-ui/`

- Requires an Azure DevOps Personal Access Token (PAT) to authenticate requests.

- If the PAT is missing, the plugin will **warn and skip execution** instead of failing the build.

- If the `brand` option is missing or invalid, the plugin will **throw an error** and stop the build.
  Valid values are:
  - `LendDirect`
  - `Cash Money`
  - `Heights Finance`
  - `Attain Finance`

---

## Global Data Context Hook

The plugin automatically provides a **Global Data Context** containing:
- `blogs` (All blog posts for the brand)
- `trustpilotReviews` (Trustpilot business data + recent 5-star reviews)
- `disclaimers` (Brand-specific disclaimers)
- `faqs` (Brand-specific FAQs)

This data is injected into the context of every page created by the plugin and is accessible in any React component via the `useCmsData` hook.

### Usage

Import `useCmsData` directly from the package:

```tsx
import { useCmsData } from "gatsby-attainlabs-cms";

const MyComponent = () => {
  const { blogs, trustpilotReviews, disclaimers, faqs } = useCmsData();

  return (
    <div>
      {/* Example: Display Trustpilot star rating */}
      {trustpilotReviews && (
          <div>{trustpilotReviews.businessData.stars} Stars</div>
      )}

       {/* Example: List Disclaimers */}
      {disclaimers?.map((d) => (
        <div key={d.id} dangerouslySetInnerHTML={{ __html: d.content }} />
      ))}
    </div>
  );
};

Troubleshooting

PAT missing warning

If you see:


⚠️ [gatsby-attainlabs-cms] No PERSONAL_ACCESS_TOKEN found...

➡️ Double-check that .env exists and is loaded in gatsby-config.js.


Invalid brand option

If you see:


[gatsby-attainlabs-cms] Invalid or missing "brand" option.
You must specify one of: LendDirect, Cash Money, Heights Finance

➡️ Make sure you pass a valid brand in gatsby-config.js.


Token in client code

Don’t use GATSBY_PERSONAL_ACCESS_TOKEN. That will leak your secret into the browser bundle. Always use PERSONAL_ACCESS_TOKEN.