@slicemachine/adapter-nuxt - v0.1
@slicemachine/adapter-nuxt
adds support for Nuxt in Slice Machine.
This package works in a Nuxt project with slice-machine-ui
installed.
The best way to configure a project with Slice Machine is by running the following command in a Nuxt project. This command will install @slicemachine/adapter-nuxt
along with other Prismic packages and add Prismic-specific configurations to your project.
npx @slicemachine/init@latest
For more information on configuring a Nuxt project with Slice Machine, see our Nuxt guide.
If you want to install this package on its own, run this command:
npm install --save-dev @slicemachine/adapter-nuxt
{
"repositoryName": "example-prismic-repository",
"adapter": "@slicemachine/adapter-nuxt",
"libraries": ["./slices"],
"localSliceSimulatorURL": "http://localhost:3000/slice-simulator"
}
You can also specify options for the adapter:
{
"repositoryName": "example-prismic-repo",
"adapter": {
"resolve": "@slicemachine/adapter-nuxt",
"options": {
"lazyLoadSlices": true
}
},
"libraries": ["./slices"]
}
Here are the available options:
format
boolean
Determines if generated files should be formatted using Prettier (default: true
).
lazyLoadSlices
boolean
Determines if slice index files should lazy load slice components using defineAsyncComponent
(default: true
).
typescript
boolean
Determines if generated files should use TypeScript rather than JavaScript (default: true
only if the project contains a tsconfig.json
file, otherwise false
).
In order to simulate slices in Slice Machine, the adapter requires a page that returns the <SliceSimulator>
component from @slicemachine/adapter-nuxt
. The URL for this page should be specified in the localSliceSimulatorURL
property of slicemachine.config.json
.
<template>
<SliceSimulator #default="{ slices }">
<SliceZone :slices="slices" :components="components" />
</SliceSimulator>
</template>
<script setup lang="ts">
import { SliceSimulator } from "@slicemachine/adapter-nuxt/simulator";
import { components } from "~/slices";
</script>
Can't find what you're looking for?
Need technical Support? Spot an error in the documentation? Get in touch with us on our Community Forum.