Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

storyblok-generator

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

storyblok-generator

Generate Storyblok components out of your components.json file and get full type-safety and bundle splitting out of the box

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
0
Weekly downloads
 
Created
Source

Storyblok Generator

GitHub Repo stars npm GitHub npm npm GitHub top language

Storyblok React component generator for Vite Storyblok apps (React/Remix.run).

  • Pulls in your components from Storyblok and generates the types for you.
  • Generates the components in either a file or folder structure.
  • Makes all components editable via the bridge by default.
  • Adds per component bundle splitting for better performance.
  • Adds full typesafety to your components.
  • Supports both kebab-case and camel-case file names.
  • Adds shortcuts to regenerate the components and types.

Setup

To get up and running quickly, you first install the vite plugin as a dev dependency in your project.

npm install -D storyblok-generator

Then, in your vite.config.ts file, add the following:

import { storyblokPlugin } from "storyblok-generator"

export default defineConfig({
	plugins: [
		storyblokPlugin({
			spaceId: "<your space id>",
			componentsDir: "./storyblok/components",
		}),
	],
})

Usage

Once the plugin is installed and configured, it will generate the components and types for you. You can then import the components in your code and use them as you normally would.

import { components } from "./storyblok/components";
import { storyblokInit, apiPlugin } from "@storyblok/react"

storyblokInit({
	accessToken: "<your access token>",
	use: [apiPlugin],
	// You pass in the components here, the components will be lazy loaded when actually used.
	components,
})

Storyblok CLI Caveats

The Plugin uses the Storyblok CLI to pull the components from your Storyblok space. This means that you need to have the CLI installed on your machine and available in your path.

You will also need to be logged in to the Storyblok CLI properly. You should login via SSO instead of using the username and password combo as that keeps you logged in but after some time the login expires and you need to login again by first logging out and logging in again.

Configuration

The plugin accepts the following configuration options:

OptionTypeDescriptionDefaultRequired
spaceIdstringYour Storyblok space ID.-Yes
componentsDirstringThe directory where the components will be generated.-Yes
typeFileLocstringThe location of the type file../storyblok/types.d.tsNo
pullCommandstringThe command to use to pull the components from Storyblok via the CLIstoryblok pull-components --space <spaceId> --path <pathToComponentsDir>No
typesCommandstringThe command to use to generate the types for the components via the CLIstoryblok generate-typescript-typedefs --sourceFilePaths <pathToComponentsDir> --destinationFilePath <pathToTypeFileLoc>No
componentsJsonLocstringThe location of the components JSON file../storyblok/components.<spaceId>.jsonNo
fileNameConventionstringThe file name convention for the components. Can be either kebab-case or camel-case.kebab-caseNo
componentAsstringThe component structure. Can be either file or folder.fileNo
debugbooleanWhether to enable debug mode. If enabled, the plugin will print additional information to the console.falseNo

Development

To develop this plugin, you can clone the repository and run the following commands:

npm install
npm run dev

This will build the plugin, install the dependencies, and start the development server.

Keywords

FAQs

Package last updated on 23 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc