vsf2-strapi-cms
v1.0.1
Published
<img src="https://seeklogo.com/images/V/vue-storefront-logo-CAF7181087-seeklogo.com.png" alt="vsf logo" width="100px" height="100px" /> <p style="font-size: 100px; display: inline; margin: 0 20px; line-height: 200px; height: 200px;">+</p> <img src="https:
Downloads
2
Maintainers
Readme
Strapi CMS v4 Vue Storefront Integration / Nuxt
Steps
- VSF Installation Steps
- Strapi Installation
VSF Installation
:rocket:
yarn add vsf2-strapi-cms
- add confiuguration to middelware.config.js
// ./middleware.config.js
module.exports = {
integrations: {
...
strapi: {
location: "vsf2-strapi-cms/server",
configuration: {
url: 'http://localhost:1337',
prefix: '/api',
axiosOptions: {},
}
}
...
}
}
- add vsf2-strapi-cms to build modules
// nuxt.config.js
buildModules: [
['@vue-storefront/nuxt', {
useRawSource: {
dev: [
'@vue-storefront/core',
...,
'vsf2-strapi-cms'
],
prod: [
'@vue-storefront/core',
...,
'vsf2-strapi-cms'
]
}
}]
],
modules: [
['vsf2-strapi-cms/nuxt', {
imageHost: 'http://localhost:1337/'
} ],
]
- add cms components to
nuxt.config.js
, see docs
export default {
...
components: ['~/components/cms'],
...
}
Usage
// .vue component
import { useContent } from 'vsf2-strapi-cms'
import { onSSR } from '@vue-storefront/core'
export default {
setup() {
const { search: searchContent, loading, content, error } = useContent()
onSSR(async () => { // or `useFetch` in nuxt composition api
await searchContent({
contentType: "blog-posts",
find: true,
sort: "Title"
})
});
return {
loading,
content,
error
}
}
}
Strapi Installation
Installing Strapi Models
These instructions are to be followed in your strapi cms codebase.
- Copy contents of
api
folder to existing./src/api
folder. If theapi
folder doesn't exist create it. - Copy over component folder. create component folder it one doesn't exist already.
yarn add strapi-plugin-populate-deep
see https://market.strapi.io/plugins/strapi-plugin-populate-deep this package was needed so strapi would return content array in Dynamic Zones. This package returns all fields and media objects