Skip to content

Instantly share code, notes, and snippets.

@DominikAngerer
Created August 13, 2021 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DominikAngerer/3804c499aa9950a98d796b6090114f46 to your computer and use it in GitHub Desktop.
Save DominikAngerer/3804c499aa9950a98d796b6090114f46 to your computer and use it in GitHub Desktop.
Export Storyblok Component Names
// Install dependency: npm install storyblok-js-client
const StoryblokClient = require('storyblok-js-client')
// This token allows CRUD operations to all your spaces and can be found in the
// "my account" section of our app: https://app.storyblok.com/#!/me/account
// DO NOT COMMIT THAT OAUTHTOKEN!!
const oauthToken = 'your_oauth_token'
// Initialize the client with the oauth token
const Storyblok = new StoryblokClient({
oauthToken: oauthToken
})
// The space id you want to check - can be found in your spaces settings
const spaceId = '51455'
const start = async () => {
let componentNames = []
// Some more output, so you see what is going on here
console.log('Loading list of components')
// load information of first 100 components - otherwise we would need to use paging as 100 is max.
let components = await Storyblok.get(`spaces/${spaceId}/components/`, { per_page: 100 })
// loop through all components
for (let index = 0, max = components.data.components.length; index < max; index++) {
let component = components.data.components[index];
// Some more output, so you see what is going on here
let componentObject = {
name: component.name,
display_name: component.display_name
}
componentNames.push(componentObject)
}
console.table(componentNames)
}
start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment