This is the Storyblok ruby client for easy access of the content delivery api.
gem 'storyblok'
client = Storyblok::Client.new(token: 'YOUR_TOKEN')
# Optionally set a cache client
Storyblok::Cache.client = Redis.new(:url => 'redis://localhost:6379')
# Get a story
client.story('home')
# Get all Stories that start with news
client.stories({
:starts_with => 'news'
})
# Get all label datasource entries
client.datasource_entries({
:datasource => 'labels'
})
# Get all Tags that within the folder news
client.tags({
:starts_with => 'news'
})
tree = client.tree
puts '<ul>'
tree.each do |key, item|
puts '<li>' + item['item']['name']
if !item['children'].empty?
puts '<ul>'
item['children'].each do |key, inner_item|
puts '<li>' + inner_item['item']['name'] + '</li>'
end
puts '</ul>'
end
puts '</li>'
end
puts '</ul>'
This project is open-sourced software licensed under the MIT license