Package Exports
- @shopware/cms-base-layer
- @shopware/cms-base-layer/nuxt.config.ts
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@shopware/cms-base-layer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
shopware/frontends - cms-base
Nuxt layer that provides an implementation of all CMS components in Shopware based on utility-classes using atomic css syntax (UnoCss / Tailwind).
It is useful for projects that want to use the CMS components but design their own layout.
Features
- Vue components for Shopping Experiences CMS
- CMS sections, blocks and elements styled using Tailwind CSS classes
- 🚀 Empowered by @shopware/composables
Setup
Install npm package:
# ✨ Auto-detect
npx nypm install -D @shopware/cms-base-layer
# npm
npm install -D @shopware/cms-base-layer
# yarn
yarn add -D @shopware/cms-base-layer
# pnpm
pnpm install -D @shopware/cms-base-layer
# bun
bun install -D @shopware/cms-base-layer
# deno
deno install --dev @shopware/cms-base-layer
Then, register the Nuxt layer in nuxt.config.ts
file:
// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
extends: ["@shopware/composables/nuxt-layer", "@shopware/cms-base-layer"],
shopware: {
endpoint: "https://demo-frontends.shopware.store/store-api/",
accessToken: "SWSCBHFSNTVMAWNZDNFKSHLAYW",
},
modules: ["@shopware/nuxt-module"],
/**
* Commented because of the StackBlitz error
* Issue: https://github.com/shopware/frontends/issues/88
*/
typescript: {
// typeCheck: true,
strict: true,
},
telemetry: false,
});
Basic usage
Since all CMS components are registered in your Nuxt application, you can now start using them in your template (no imports needed):
/* Vue component */
// response object can be a Product|Category|Landing Page response from Shopware 6 store-api containing a layout (cmsPage object) built using Shopping Experiences
<template>
<CmsPage v-if="response.cmsPage" :content="response.cmsPage"/>
</template>
You can use default styling by installing/importing Tailwind CSS stylesheet in your project.
See a short guide how to use cms-base
package in your project based on Nuxt v3.
📘 Available components
The list of available blocks and elements is here.
🔄 Overwriting components
The procedure is:
- find a component in component's list, using a Vue devtools or browsing the github repository
- take its name
- create a file with the same name and place it into
~/components
dir in your nuxt project (or wherever according your nuxt config)
✅ Thanks to this, nuxt will take the component registered in your app instead of the one registered by this nuxt layer.
Internal components
❗Internal components are not a part of public API. Once overwritten you need to track the changes on your own.
There is also a possibility to override the internal components, shared between public blocks and elements, the ones starting with Sw
prefix, like SwSlider.vue or SwProductCard.vue.
An example: some components use SwSharedPrice.vue
to show prices with corresponding currency for products in many places like product card, product details page and so on. In order to change the way how the price is displayed consistently - create a one component with a name SwSharedPrice.vue
and that's it. The new component will be used everywhere where is "imported" (autoimported actually).
⚠️ <RouterLink/>
components used
Some components use RouterLink
component internally, available in Vue Router.
In order to parse CMS components correctly and avoid missing component warning, it's highly recommended to have Vue Router installed or Nuxt router enabled in your application.
TypeScript support
All components are fully typed with TypeScript.
No additional packages needed to be installed.
Links
👥 Community (
#composable-frontends
)
Changelog
Full changelog for stable version is available here
Latest changes: 1.5.1
Patch Changes
#1879
eaf170b
Thanks @acuriouspotion! - Fix youtube player control display and usage of advanced privacy mode setting.#1862
20fd2c6
Thanks @aheartforspinach! - Fix CmsSectionSidebar.vue when used on a landing page by removing useCategory and related code#1884
3004b97
Thanks @MorennMcFly! - Fix cms blocks TextTeaserSection and TextTwoColumn responsivity so the elements stack from md breakpoint and under.#1863
f8c5cd5
Thanks @aheartforspinach! - moveCmsBlockHtml.vue
to block folder (instead of element), removeCmsBlockHtml.md
Updated dependencies [
ab040bb
,c8fa438
]:- @shopware/composables@1.9.1
- @shopware/helpers@1.5.0