Get Started
Installation
Learn how to install and configure the vue-craftcms package.
Requirements
- The Craft Query API plugin must be installed and properly configured in Craft CMS.
- Vue 3 is required.
Install
npm install -D vue-craftcms
You can register vue-craftcms
Package with the craftcms
property in your main.ts file.
main.ts
import { CraftCms } from '@vue-craftcms';
import { createApp } from 'vue';
import App from './App.vue';
const app = createApp(App);
/* const defaults = {
baseUrl: '', // Required
registerComponents: true,
debug: false,
enableEntryTypeMapping: true,
siteMap: [],
}; */
// A valid config could look like that
app.use(CraftCms, {
baseUrl: 'https://example.ddev.site',
registerComponents: true,
debug: false,
enableEntryTypeMapping: true,
siteMap: [
{
handle: 'en',
origin: 'http://localhost:3000',
id: 1,
},
{
handle: 'de',
origin: 'http://localhost:3000/de',
id: 2,
},
],
});
app.mount('#app');
- baseUrl: Refers to the PRIMARY_SITE_URL of Craft CMS, without a trailing slash.
- debug: Enables debug mode and log built urls
- registerComponents: Globally register all components
- enableEntryTypeMapping: This allows the
CraftPage
component to automatically detect your entries based on their section handle and entry type. - siteMap: Define an array of sites to enable multisite support. Each site object must include a handle and an origin.
Boom, finished. 🚀