Bootstrapping Nuxt
This documentation explains how to get started with the integration in a Nuxt 3 application.
Requirements
- Nuxt 3 project,
- Contentful space,
- Node.js version
16.x
, - @vsf-enterprise NPM registry access.
Something's missing?
If you don't have a Nuxt 3 project yet, create one by following the official guide. If you don't have a Contentful space yet, we suggest you get in touch with Contentful and request a demo.
Creating .npmrc
file
In order to start working with our enterprise packages, add a .npmrc
file with the following content to the root of your repository:
@vsf-enterprise:registry=https://registrynpm.storefrontcloud.io
Importing integration files
Vue Storefront ships with a CLI tool for CMS integrations which will import all of the frontend acceleration files into your project.
The CLI tool has been tested with a fresh Nuxt 3 project.
To use the CLI, simply run the following command from the root of your project:
npx @vsf-enterprise/cms-cli contentful nuxt
This will create (or overwrite) the following files in your project:
├── components
│ └── cms
│ ├── layout
│ │ ├── Footer.vue
│ │ └── MegaMenu.vue
│ ├── page
│ │ ├── Accordion.vue
│ │ ├── Banner.vue
│ │ ├── Card.vue
│ │ ├── Editorial.vue
│ │ ├── Gallery.vue
│ │ ├── Grid.vue
│ │ ├── Hero.vue
│ │ ├── NewsletterBox.vue
│ │ ├── ProductCard.vue
│ │ └── Scrollable.vue
│ └── wrappers
│ └── RenderComponent.vue
├── layouts
│ └── contentful.vue
├── pages
│ └── [...slug].vue
└── schemas
└── schemas.json
Layouts must be enabled
The contentful.vue
layout will only take effect when the NuxtLayout component is used within the app.vue component.
<template>
<NuxtLayout />
</template>
Installing dependencies
The UI layer of the integration relies on Storefront UI and its dependencies. Follow the official guide to install the library in your project.
You will also need to install other integration dependencies such as supplementary packages related to Storefront UI or agnostic CMS components. Run the following command to install them in your project:
# npm
npm install @storefront-ui/typography @nuxtjs/google-fonts @vsf-enterprise/cms-components-utils
# yarn
yarn add @storefront-ui/typography @nuxtjs/google-fonts @vsf-enterprise/cms-components-utils
Loading fonts
The default Storefront UI setup uses Google Fonts. One way to loading these fonts to your project is by installing the @nuxtjs/google-fonts module in your project and adding the following lines to your nuxt.config.ts:
export default defineNuxtConfig({
// ...
modules: [
// ...
['@nuxtjs/google-fonts', {
families: {
'Red Hat Display': [400, 500, 700],
'Red Hat Text': [300, 400, 500, 700]
}
}]
]
});
To complete the fonts setup, add the following Storefront UI typography configuration to your Tailwind config file:
import sfTypography from '@storefront-ui/typography';
export default {
// ...
plugins: [sfTypography],
theme: {
fontFamily: {
sans: 'Red Hat Text, sans-serif',
}
}
};
What next?
Now your frontend application has the scaffolding required to display dynamic CMS components. However, it also needs an engine to fetch the data from Contentful. Proceed to the Middleware and SDK setup guide and learn how to install it.