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

glorybook

v1.2.1

Published

Webpack plugin for creating storybook pages from contentful data

Downloads

10

Readme

Image of contentful-, webpack- and storybook logo

Glorybook

A webpack plugin to use in conjunction with @storybook/addons-docs.

Will take your contentful data and turn it into a markdown file that storybook can read.

Install

npm i --save-dev glorybook
yarn add --dev glorybook

Usage

The plugin will fetch data from the supplied contentful space, and output .mdx-files inside your webpack /src-folder. By default the created files are put in a subfolder named /contentful.

Be sure to not expose your space/access token in your public code

webpack.config.js

const GlorybookPlugin = require("glorybook");

module.exports = {
  plugins: [
    new GlorybookPlugin({
      space: 'contentful space id', // required
      accessToken: 'contentful access token' // required
    })
  ]
}

Example

This setup in your contentful content model:
Screenshot of contentful UI

Will output this in storybook:
Screenshot of storybook UI

With a file structure like this:

📦src
 ┗ 📂contentful
   ┗ 📂parent
     ┗ 📂child-folder
       ┗ 📜nested-page.stories.mdx

The plugin can currently handle

  • Rich text
  • Images (single)
  • Videos (single)
  • Referenced content, including all of the above

Options

| Name | Type | Default | Description | | ---------------- | ---------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------ | | environment | {String} | 'master' | Defines what contentful environment you want to get data from. | | srcFolder | {String} | '/src' | Defines where your src-folder lives. | | subFolder | {String} | '/contentful' | Defines where the generated files will be put, inside the srcFolder | | contentTypeId | {String} | 'page' | The id of your contentful pages that you like to fetch | | additionalHead | {String} | '' | If you have more content you like to paste in the top of every file | | camelCase | {Bool} | false | If you want the generated files to be named in in camelCase. When false, they will be in kebab-case | | fullPathOutput | {Bool} | false | When the page is nested, this will keep the full relative path in the filename. When false, only the last part will be kept. | | nestedOutput | {Bool} | true | If the files should be placed in folders just like in storyfull. false will place all files in the,un-nested , subFolder | | labelDefinedBy | {String} | 'label' | The id your contentful entry that defines label the file will be placed under | | pathDefinedBy | {String} | 'path' | The id your contentful entry that defines what path/filename the file will get |


Dev-notes

The /demo-folder is used for previewing any test output during development of this plugin.
This folder has a copy of storybook installed in order for us to run the plugin and have a real-world environment to sandbox in.

For getting started with building on this project, run:

yarn inst

This will install all dependencies needed for both the plugin, and the demo environment.

When any changes are made ...

yarn build

... will output files, applying the passed options specified in the webpack.config.js

yarn demo

Can be run in order to build and startup the storybook inside /demo. This is currently used for testing. In a very WYSIWYG-fashion.