nuxt-newt
v1.3.5
Published
Newt integration for Nuxt
Downloads
11
Readme
nuxt-newt
Quick Setup
- Install the module to your Nuxt application with one command
npx nuxi module add nuxt-newt
- Add
spaceUid
andcdnApiToken
to thenewt
section ofnuxt.config.ts
export default defineNuxtConfig({
modules: ["nuxt-newt"],
newt: {
spaceUid: process.env.NEWT_SPACE_UID,
cdnApiToken: process.env.NEWT_CDN_API_TOKEN,
},
})
- Add your Newt
spaceUid
andcdnApiToken
to the.env
file
NEWT_SPACE_UID='YOUR_SPACE_UID'
NEWT_CDN_API_TOKEN='YOUR_CDN_API_TOKEN'
Usage
useNewtGetContents: Get contents
<script setup lang="ts">
const { data } = await useNewtGetContents<T>(key, {
appUid: 'YOUR_APP_UID',
modelUid: 'YOUR_MODEL_UID',
query: {
// Add your query here (optional)
},
});
</script>
useNewtGetContent: Get a content
<script lang='ts' setup>
const { data } = await useNewtGetContent<T>(key, {
appUid: 'YOUR_APP_UID',
modelUid: 'YOUR_MODEL_UID',
contentId: 'YOUR_CONTENT_ID',
query: {
// Add your query here (optional)
},
});
</script>
useNewtGetFirstContent: Get first content
<script lang='ts' setup>
const { data } = await useNewtGetFirstContent<T>(key, {
appUid: 'YOUR_APP_UID',
modelUid: 'YOUR_MODEL_UID',
query: {
// Add your query here (optional)
},
});
</script>
query details
Contribution
# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run ESLint
npm run lint
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release