Example usage in Storyblok with demo components
Copy packages/vsf-storyblok-module
to vue-storefront/src/modules
.
Add the following to vue-storefront/src/modules/index.ts
import { extendModule } from '@vue-storefront/core/lib/module'
...
import { Storyblok, urlExtend } from './vsf-storyblok-module';
extendModule(urlExtend)
export const registerModules: VueStorefrontModule[] = [
...
Storyblok
]
"storyblok": {
"endpoint": "http://localhost:8080/api/ext/vsf-storyblok-extension"
}
See the /theme
folder for a demo implementation.
Notable paths:
components/storyblok
- Directory with a few demo componentsindex.js
- How to register components
To be used with the Weblink/Storylink
field type (https://www.storyblok.com/docs/terminology/field-type)
<sb-router-link :link="item.link">{{ item.title }}</sb-router-link>
Wrapper around the Storyblok Image Server API - https://www.storyblok.com/docs/image-service
height
Height in pixels
width
Width in pixels
src
Original path to image from Image
Field Type
div
If set to true you can instead use this component as a div with background. Example: <sb-img :src="item.background">My content here</sb-img>
smart
A smart filter that crops around the focal point, which is determined by a smart algorithm
fit-in
The fit-in argument specifies that the image should not be auto-cropped but auto-resized (shrunk) to fit inside an imaginary box of width and height, instead.
filters
Array of filters to apply. For example <sb-img :src="item.imageSrc" :width="800" :height="200" :fit-in="true" :filters="['fill(CCCCCC)', 'format(png)']" />
lazy
If true the image will be lazy loaded. Does not work if div
is true
Copy packages/vsf-storyblok-extension
to vue-storefront-api/src/api/extensions
.
"registeredExtensions": ["vsf-storyblok-extension"],
...
"storyblok": {
"previewToken": "__API_KEY_HERE__",
"hookSecret": "__SECRET_CHANGE_ME__"
}
Go to https://app.storyblok.com/#!/me/spaces/YOUR_SPACE_ID/edit?tab=api
and generate a preview token.
On the backend we use it to fetch posts when the webhook is polled. In the UI it's used for the preview functionality in Storyblok.
The URL the UI tries to fetch stories from
If this field is defined you have to provide this secret as a query param for your webhook. For example:
http://localhost:8080/api/ext/vsf-storyblok-extension/hook
would be
http://localhost:8080/api/ext/vsf-storyblok-extension/hook?secret=__SECRET_CHANGE_ME__
from our example config above. The secret is never needed in development mode.
To sync all posts there's a hook available at http://localhost:8080/api/ext/vsf-storyblok-extension/hook
Follow the Storyblok documentation to enable it: https://www.storyblok.com/docs/Guides/using-storyblok-webhooks
git clone --recurse-submodules http://github.com/kodbruket/vsf-storyblok-sync.git
docker-compose up
Visit http://localhost:3000/ci to see it in action
docker-compose exec storefront-api yarn mage2vs import
docker-compose exec storefront-api yarn restore
docker-compose exec storefront-api yarn migrate