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

addon-confluence

v0.0.32

Published

An addon to implement Confluence documentation in StoryBook.

Downloads

3,515

Readme

Storybook Addon confluence-addon

An addon to implement Confluence documentation in Storybook.

Getting started

Walkthrough Video Tutorial

Watch the video

1. Install

npm install -D addon-confluence

yarn add -D addon-confluence

pnpm add -D addon-confluence

2. Register the addon in `.storybook/main.js and add the staticDirs configuration to serve the 'public' directory."

To ensure that the Confluence documentation is accessible to your Storybook application, you need to configure Storybook to serve the public directory where the fetched documentation is stored.

export default {
  addons: [
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    "addon-confluence", // Add this line to register the addon
  ],
  staticDirs: ["public"], // Add this line to serve the 'public' directory
};

3. Create a token for Confluence!

Go to this link and create an API Token for your account. Then add it along with the email for your account to a .env file as so.

[email protected]
STORYBOOK_CONFLUENCE_TOKEN=YourTokenHere!

4. Add a confluence.js file to your .storybook directory.

The file name must be "confluence.js". This will be the target for the script that fetches the documentation at build time. The default export must be an array of objects with domain and id keys.

const domain = "your-domain";

const confluence = [
  // Add your (domain, id) pairs here
  { domain: domain, id: "4166582285" },
  { domain: domain, id: "4166844417" },
  { domain: "different-domain", id: "4166844418" },
];
// This can be named anything but it must be a default export of an array of objects with `domain` and `id` keys.
export default confluence;

5. Add a confluence ID to your story!

Next, we need add a page id to the story. You can find this within the url while viewing the desired Confluence page. We only need the id for this step but we will need your_domain for the next step.

For example: https://<your_domain>.atlassian.net/wiki//pages/<your_page_id>/Example_Page_Name

Then simply add "confluence" as an object to your story. And then add the id as its property:

export default {
  title: "My stories",
  component: Button,
};

export const myStory = {
  parameters: {
    confluence: {
      id: 12345678,
    },
  },
};

6. Add Scripts to package.json

To ensure that the fetchDocs script runs automatically before building Storybook, you need to update your project’s package.json by adding the prestorybook:build script and ensuring that cross-env is installed. Follow these steps:

Open your project’s package.json file and add the following scripts under the "scripts" section:

{
  "scripts": {
    // ... other scripts
   "prebuild-storybook": "fetchDocs", .// Add this line
    "storybook:build": "cross-env NODE_OPTIONS=--openssl-legacy-provider storybook build",
    // ... other scripts
  }
}

If you have a different build script, prerfix pre to your build script. and set the value to fetchDocs as shown above.

7. Injecting Environment Variables in GitHub Actions

Start by adding a new secret to your GitHub repository. Navigate to your repository on GitHub, click on the "Settings" tab, and then click on "Secrets" in the left-hand sidebar. Click on the "New repository secret" button, and add the following secrets:

  • STORYBOOK_CONFLUENCE_EMAIL: The email address associated with your Confluence account.
  • STORYBOOK_CONFLUENCE_TOKEN: The API token generated for your Confluence account.

If you are using Chromatic for deployment and need to inject environment variables into your hosted Storybook, update your .github/workflows/chromatic.yml file as follows:

.github/workflows/chromatic.yml
jobs:
  chromatic:
    steps:
      # ... other steps

      - uses: chromaui/action@latest
        with:
          projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
        env:
          # 👇 Sets the environment variable
          STORYBOOK_CONFLUENCE_EMAIL: ${{ secrets.STORYBOOK_CONFLUENCE_EMAIL }}
          STORYBOOK_CONFLUENCE_TOKEN: ${{ secrets.STORYBOOK_CONFLUENCE_TOKEN }}

By adding this configuration, your Storybook environment variables will be correctly injected during the Chromatic deployment process.

Example Image - Storybook - Confluence-addon